This is the mail archive of the binutils@sourceware.org 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: [PATCH] change the condition preventing symbol replacement in snapshot_symbol()


On Mon, Jul 27, 2009 at 10:33 AM, H.J. Lu<hjl.tools@gmail.com> wrote:
>> I extended H.J.'s demonstration slightly:
>>
>> ?bar = foo
>> ?baz = globule
>>
>> ? ? ? ?.globl foo
>> ? ? ? ?.globl globule
>> ?foo:
>> ? ? ? ?jmp bar
>> ? ? ? ?jmp foo
>> ? ? ? ?jmp baz
>> ? ? ? ?jmp globule
>>
>> Which when assembled and dumped with objdump -dr gives:
>>
>> 00000000 <foo>:
>> ? 0: ? eb fe ? ? ? ? ? ? ? ? ? jmp ? ?0 <foo>
>> ? 2: ? e9 fc ff ff ff ? ? ? ? ?jmp ? ?3 <foo+0x3>
>> ? ? ? ? ? ? ? ? ? ? ? ?3: R_386_PC32 ? foo
>> ? 7: ? e9 fc ff ff ff ? ? ? ? ?jmp ? ?8 <foo+0x8>
>> ? ? ? ? ? ? ? ? ? ? ? ?8: R_386_PC32 ? globule
>> ? c: ? e9 fc ff ff ff ? ? ? ? ?jmp ? ?d <foo+0xd>
>> ? ? ? ? ? ? ? ? ? ? ? ?d: R_386_PC32 ? globule
>>
>> The first jmp just seems plain wrong to me. ?I would expect it to have a
>> relocation against the foo symbol just like all of the others.
>
> That is a bug. I will look into it.
>

That isn't a bug. The reasons are

1. foo is defined and global.
2. bar is defined and local, which has the same type and value as foo.
3. baz is undefined, which has has the same type and value as globule.
4. globule is undefined.

The real bug is

[hjl@gnu-6 tmp]$ cat b.s
  bar = foo
  baz = globule
 .hidden baz

       .globl foo
       .globl globule
 foo:
       jmp bar
       jmp foo
       jmp baz
       jmp globule
[hjl@gnu-6 tmp]$ gcc -c b.s
[hjl@gnu-6 tmp]$ objdump -dr b.o

b.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <foo>:
   0:	eb fe                	jmp    0 <foo>
   2:	e9 00 00 00 00       	jmpq   7 <foo+0x7>
			3: R_X86_64_PC32	foo-0x4
   7:	e9 00 00 00 00       	jmpq   c <foo+0xc>
			8: R_X86_64_PC32	globule-0x4
   c:	e9 00 00 00 00       	jmpq   11 <foo+0x11>
			d: R_X86_64_PC32	globule-0x4
[hjl@gnu-6 tmp]$

Now baz shouldn't be an alias of globule since it should be hidden.

-- 
H.J.


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