This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [discuss] Re: Visibility=hidden for x86_64 Xen builds -- problems?
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Keir Fraser <Keir dot Fraser at cl dot cam dot ac dot uk>
- Cc: Jan Beulich <jbeulich at novell dot com>, gcc at gcc dot gnu dot org, binutils at sourceware dot org, discuss at x86-64 dot org
- Date: Thu, 28 Sep 2006 17:40:41 -0700
- Subject: Re: [discuss] Re: Visibility=hidden for x86_64 Xen builds -- problems?
- References: <C1419AD3.1C54%Keir.Fraser@cl.cam.ac.uk> <C1419BB1.1C58%Keir.Fraser@cl.cam.ac.uk>
On Thu, Sep 28, 2006 at 03:33:05PM +0100, Keir Fraser wrote:
>
> > 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 100000000 -o test test.o
> >
> > Disassembly of the result trivially shows that the address of weak symbol 'x'
> > is 0x100000000.
>
> 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.
You are asking for impossible:
[hjl@gnu-13 weak-4]$ objdump -dr foo.o
foo.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <_start>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 8d 05 00 00 00 00 lea 0(%rip),%rax # b
<_start+0xb>
7: R_X86_64_PC32 x+0xfffffffffffffffc
b: c9 leaveq
c: c3 retq
R_X86_64_PC32 only supports signed 32bit offset. 0x100000000 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.
H.J.