Re: Visibility=hidden for x86_64 Xen builds -- problems?

2006-09-28 Thread Keir Fraser
On 28/9/06 14:24, "H. J. Lu" <[EMAIL PROTECTED]> wrote:

> On Thu, Sep 28, 2006 at 10:45:38AM +0100, Jan Beulich wrote:
>> 
>> 2) Why does the linker silently resolve the (32-bit PC-relative)
>> relocation targeting an undefined weak symbol, yielding at
>> run-time a non-zero address? While I can see the point of
> 
> Do you have a testcase? I can't reproduce it. If it is true, I consider
> it a linker bug.

Compile and link the attached C program as follows. I used gcc-4.1.1 and
binutils-2.17, but gcc >= 4.0.0 and binutils >= 2.16 probably suffice.

 # gcc -fpic -o test.o -c test.c
 # ld -Ttext 1 -o test test.o

Disassembly of the result trivially shows that the address of weak symbol
'x' is 0x1.

 -- Keir



test.c
Description: Binary data


Re: Visibility=hidden for x86_64 Xen builds -- problems?

2006-09-28 Thread Keir Fraser

> Compile and link the attached C program as follows. I used gcc-4.1.1 and
> binutils-2.17, but gcc >= 4.0.0 and binutils >= 2.16 probably suffice.
> 
>  # gcc -fpic -o test.o -c test.c
>  # ld -Ttext 1 -o test test.o
> 
> Disassembly of the result trivially shows that the address of weak symbol 'x'
> is 0x1.

By the way, experimentation with the address of the text section shows that
the weak symbol's address is resolved to the nearest 4GB-aligned address
(nearest to what I'm not sure -- RIP? Section start?). It may get rounded up
or down, whichever is nearest.

 -- Keir




Re: [discuss] Re: Visibility=hidden for x86_64 Xen builds -- problems?

2006-09-28 Thread Keir Fraser
On 29/9/06 1:40 am, "H. J. Lu" <[EMAIL PROTECTED]> wrote:

> You are asking for impossible:

If the compiler emitted accesses via the GOT for weak symbols then there
wouldn't be a problem. The compiler doesn't know the final link address
though, so it'd have to be conservative. Perhaps it's not worth it for a
case that noone much cares about.

> R_X86_64_PC32 only supports signed 32bit offset. 0x1 is more
> than 32bit. The linker should issue an error, at least a warning. You
> can take your pick and I will fix the linker. If no one objects, I
> will make it an error.

That's fine with us. I fixed Xen to no longer use weak symbols.

 -- Keir