[PATCH PROPOSAL] Bcc: output an import directive on external function declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
     {

--
To unsubscribe from this list: send the line "unsubscribe linux-8086" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel]     [Linux ia64]     [DCCP]     [Linux for ARM]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux