All of lore.kernel.org
 help / color / mirror / Atom feed
From: MFLD <mfld.fr@gmail.com>
To: ELKS <Linux-8086@Vger.Kernel.Org>
Cc: Robert de Bath <"robert$"@debath.co.uk>, lkundrak@v3.sk
Subject: [PATCH PROPOSAL] Bcc: output an import directive on external function declaration
Date: Sat, 11 Apr 2015 21:33:13 +0200	[thread overview]
Message-ID: <552976F9.4070800@gmail.com> (raw)

Hello,

This patch tries to solve the problem described in the "Question on 
import symbols generated by BCC 
<http://news.gmane.org/find-root.php?message_id=551599A4.7060804%40gmail.com>" 
topic (see earlier in the mailing list archive). When parsing an 
external function declaration, Bcc outputs an assembler import directive 
in the code segment. So that in the object symbol table, the external 
function is flagged 'T' (= symbol in code segment) in place of 'U' (= 
undefined segment).

Unit test result (to be compared with the one in the referenced topic):

mfld@mfldhome ~/advantech/dev86/bcc $ bcc -c -o test2.o test2.c
mfld@mfldhome ~/advantech/dev86/bcc $ objdump86 test2.o
OBJECTFILE 'test2.o'
MODULE  'test2'
BYTEPOS 00000038
BINLEN  0000000c
STRINGS 0025 +0013
VERSION 0.0
SEG0 0000000c

SYMS 2
SYM 0    00000000 ..E.T _main
SYM 1    00000000 ...IT _entry

text    data    bss    dec    hex    filename
12    0    0    12    c    test2.o

BYTECODE
SEG 0
: 55 89 e5 57 56 e8 U..WV.
RELSZ 2
DW _entry-PC
: 5e 5f 5d c3 ^_].
SEG 3

-----

diff --git a/bcc/declare.c b/bcc/declare.c
index 1f0aae2..2fd7239 100644
--- a/bcc/declare.c
+++ b/bcc/declare.c
@@ -834,7 +834,15 @@
          gvarsymptr->flags = DIRECTPAGE;
  #endif
          if (gvarsc == EXTERNDECL)
-        gvarsymptr->flags |= EXTERNAL;
+        {
+            gvarsymptr->flags |= EXTERNAL;
+            if (gvartype->constructor == FUNCTION)
+            {
+                /* Output an assembler import directive in code segment */
+                cseg ();
+                import (gvarname);
+            }
+        }
      }
      else
      {


                 reply	other threads:[~2015-04-11 19:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=552976F9.4070800@gmail.com \
    --to=mfld.fr@gmail.com \
    --cc=Linux-8086@Vger.Kernel.Org \
    --cc=lkundrak@v3.sk \
    --cc=robert$@debath.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.