This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A question about debug symbols in asm (x86)


>>    Note the -gdwarf-2. Running nm -l on the
resultant >entry.o shows lines like:
>>
>>    00000acc t common_interrupt
>>/usr/src/linux-2.6.12-rc/arch/i386/kernel/entry.S:441
>>
>>    This file is combined with a bunch of others
>>thusly:
>>
>>  
>>/opt/montavista/pro/devkit/x86/pentium3/bin/pentium3-ld
>>-m elf_i386  -R
>>arch/i386/kernel/vsyscall-syms.o -r -o
>>arch/i386/kernel/built-in.o
>>arch/i386/kernel/process.o
>>arch/i386/kernel/semaphore.o
>>
>>
>>    Running nm -l built-in.o|grep entry.S gives:
>>
>>000024cd t ldt_ss   
>>/usr/src/linux-2.6.12-rc/arch/i386/kernel/entry.S:300
>>00000000 a
>>/usr/src/linux-2.6.12-rc/arch/i386/kernel/entry.S
>>
>>
>>    I.e all most all the symbols have gone. What is
>>going on here? 
>
>
>This looks like a linker bug.

>Can you create a small testcase which reproduces this
>problem and which you can post to this list ?
>
>(I assume that you are running that latest version of
>the linker, ie version 2.16 or newer. If not they
>please try upgrading first, to see if that resolves
>the problem).


Yes, it is a ld problem. I was able to see the same
problem when ld links object files that generated from
c code with the latest binutils (2.16.90.0.3 20050510)

The test case is as the following:
(1) test files

//test1.c
static int test1_v1;
static int test1_v2;
static int test1_v3;
int main(void)
{
  return 0;
}

//test2.c
static int test2_f1(int val)
{
  return val;
}

static int test2_f2(int val)
{
  return val;
}

(2) test procedure

$ gcc -g -c test1.c -o test1.o
$ gcc -g -c test2.c -o test2.o
$ ld -r -o tt.o test2.o test1.o

$ nm -l test1.o
00000000 T main         /home/test/test1.c:5
00000000 b test1_v1     /home/test/test1.c:5
00000004 b test1_v2     /home/test/test1.c:5
00000008 b test1_v3     /home/test/test1.c:5

$ nm -l test2.o
00000000 t test2_f1     /home/test/test2.c:2
00000008 t test2_f2     /home/test/test2.c:7

$ nm -l tt.o
00000010 T main         /home/test/test1.c:5
00000000 b test1_v1     /home/test/test2.c:2 
<--wrong!
00000004 b test1_v2     /home/test/test2.c:3 
<--wrong!
00000008 b test1_v3     /home/test/test2.c:7 
<--wrong!
00000000 t test2_f1     /home/test/test2.c:2
00000008 t test2_f2     /home/test/test2.c:7


But if we change the object file order then we won't
see the problem.

$ ld -r -o tt.ok.o test1.o test2.o

$nm -l tt.ok.o
00000000 T main         /home/test/test1.c:5
00000000 b test1_v1     /home/test/test1.c:5 <--ok
00000004 b test1_v2     /home/test/test1.c:5 <--ok
00000008 b test1_v3     /home/test/test1.c:5 <--ok
00000018 t test2_f1     /home/test/test2.c:2
00000020 t test2_f2     /home/test/test2.c:7

The problem will also be gone if we don't have "-r" in
ld command.

Any advise? 


Thanks in advance,

Qunying





		
__________________________________ 
Discover Yahoo! 
Use Yahoo! to plan a weekend, have fun online and more. Check it out! 
http://discover.yahoo.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]