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: Is it possible to make the whole image above 4G on a 64 bit machine?


On Wed, Aug 29, 2012 at 3:17 AM, ³¯­³¥ô (Wei-Ren Chen)
<chenwj@iis.sinica.edu.tw> wrote:
> Hi all,
>
>   For some reason, I need to compile a program so that when it's loaded
> into memory, the whole image is above 4G virtual space (I am on a 64 bit
> machine). The space below 4G tends to be other usage. I try the following
> command,
>
> $ gcc -Wl,-Ttext-segment=0x40000000 test.c -o test
>
> I was only success to make the whole image above 1G. But when I want to
> make it above 2G, the linker give me error below:
>

> Wei-Ren Chen (³¯­³¥ô)> ---
> $ gcc -static -Wl,-Ttext-segment=0x80000000 test.c -o test
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/crt1.o: In function `_start':
> (.text+0x12): relocation truncated to fit: R_X86_64_32S against symbol `__libc_csu_fini' defined in .text section in /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/libc.a(elf-init.o)
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/crt1.o: In function `_start':
> (.text+0x19): relocation truncated to fit: R_X86_64_32S against symbol `__libc_csu_init' defined in .text section in /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/libc.a(elf-init.o)
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/crt1.o: In function `_start':
> (.text+0x20): relocation truncated to fit: R_X86_64_32S against symbol `main' defined in .text section in /tmp/ccdqj0nB.o
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/crtbeginT.o:(.text+0x21): relocation truncated to fit: R_X86_64_32S against `.dtors'
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/crtbeginT.o:(.text+0x45): relocation truncated to fit: R_X86_64_32S against `.dtors'
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/libc.a(libc-start.o):
> In function `__libc_start_main':
> (.text+0x34): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_dl_starting_up'
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/libc.a(libc-start.o): In function `__libc_start_main':
> (.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__nptl_deallocate_tsd'
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/libc.a(libc-start.o): In function `__libc_start_main':
> (.text+0x202): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__nptl_nthreads'
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/libc.a(libc-tls.o): In function `__libc_setup_tls':
> (.text+0xf3): relocation truncated to fit: R_X86_64_32S against `.bss'
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/libc.a(libc-tls.o): In function `__libc_setup_tls':
> (.text+0x18b): relocation truncated to fit: R_X86_64_32S against `.bss'
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/libc.a(libc-tls.o): In function `__libc_setup_tls':
> (.text+0x196): additional relocation overflows omitted from the output
> collect2: ld returned 1 exit status
> ---
>
>   If it's possible to make the whole image above 4G, how I can do that?
> If not, could you explain why? Thanks.
>

You must use PIE to place an executable above 4G.

-- 
H.J.


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