Obtaining current address for .stabs

John Levon levon@movementarian.org
Sun Mar 3 18:52:00 GMT 2002


I need to manually code some .stabs data via inline asm with gcc.

root linux 174 uname -a
Linux nastic 2.4.17rmap9smp #6 SMP Sat Mar 2 17:52:39 GMT 2002 i686
unknown
root linux 175 as --version
GNU assembler 2.10.90


My original code looked like this :

#define __stabs_text_lock_asm(l)               \
       ".section .text.lock,\"ax\"\n"          \
       ".stabs \"" __FILE__ "\",100,0,0,.\n"   \
       ".stabs " "\"text_lock_" #l             \
       " at " __FILE__                         \
       " line " __STRINGIFY(__LINE__)          \
       ":F(0,20)\",36,0,0,. \n"                \
       ".previous\n"

Now this is inserted before linux kernel code that generates actual
code in the .text.lock section.

This works to a degree, but the value for the second .stabs are wrong :

(objdump -g vmlinux and comments)

semaphore.c:
<undefined> text_lock_&semaphore_lock at semaphore.c line 64 ()
{ /* 0xc01f7c00 */ actually c01f7bb0 80 (+20, 8 + 12)
} /* 0xc01f7c0c */
semaphore.c:
<undefined> text_lock_&semaphore_lock at semaphore.c line 82 ()
{ /* 0xc01f7c18 */ actually c01f7bc0 88 (+8)
} /* 0xc01f7c24 */
semaphore.c:
<undefined> text_lock_&semaphore_lock at semaphore.c line 98 ()
{ /* 0xc01f7c30 */ actually c01f7bd0 96 (+8)
} /* 0xc01f7c3c */

given the differences, it seems that the .stabs data (which ends up in
.stab and .stabstr) is advancing the location counter, even though it
ends up automagically in a different section. For example it looks like
12 is added on for every file (100) entry, and 8 for every normal
function (36) entry.

Obviously this means the generated offset values are incorrect. Has
somebody a suggestion for this problem ? I have tried :

        ".section .text.lock,\"ax\"\n"          \
        ".set __text_lock_address, .\n"         \
        ".section .stabs.temp,\"a\"\n"          \
        ".stabs \"" __FILE__ "\""               \
        ",100,0,0,0\n"                          \
        ".stabs " "\"text_lock_" #l             \
        " at " __FILE__                         \
        " line " __STRINGIFY(__LINE__)          \
        ":F(0,0)\",36,0,0,__text_lock_address \n"       \
        ".previous\n"                           \
        ".previous\n"

But this asserts gas, and it's not clear it will work anyway.

Any ideas much appreciated.

regards
john


-- 
I am a complete moron for forgetting about endianness. May I be
forever marked as such.



More information about the Binutils mailing list