This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: How to get the default linker script used by gcc?
2009/5/12 Ian Lance Taylor <iant@google.com>:
> It looks like all you want is a way to get the address and size of the
> .array section. ?If you give the section a name which can be used as a
> variable name in C (i.e., no '.' character) then the linker will
> automatically define __start_SECNAME and __stop_SECNAME symbols which
> you can use.
>
> http://www.airs.com/blog/archives/56
>
> Ian
>
It doesn't seem that ld can handle __start_SECNAME and __stop_SECNAME
properly for pei-i386, but It is good for elf32-i386.
My test case is:
$dd if=/dev/urandom of=res.dat count=16
$/cygdrive/d/MinGW/bin/objcopy -I binary -O pei-i386 -B i386 res.dat res.o
$/cygdrive/d/MinGW/bin/objcopy --rename-section .data=ResData res.o
$/cygdrive/d/MinGW/bin/gcc -o a.exe main.o res.o
$nm a.exe | grep ResData
00402030 A ___start_ResData
00405000 A ___stop_ResData
$/cygdrive/d/MinGW/bin/objdump -h a.exe
a.exe: file format pei-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000009d4 00401000 00401000 00000400 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
1 .data 00000030 00402000 00402000 00000e00 2**4
CONTENTS, ALLOC, LOAD, DATA
2 ResData 00002000 00403000 00403000 00001000 2**2
CONTENTS, ALLOC, LOAD, DATA
3 .rdata 00000110 00405000 00405000 00003000 2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .bss 000000c0 00406000 00406000 00000000 2**4
ALLOC
5 .idata 00000304 00407000 00407000 00003200 2**2
CONTENTS, ALLOC, LOAD, DATA
6 .stab 00000480 00408000 00408000 00003600 2**2
CONTENTS, READONLY, DEBUGGING, EXCLUDE
7 .stabstr 00000955 00409000 00409000 00003c00 2**0
CONTENTS, READONLY, DEBUGGING, EXCLUDE
The symbol ___start_ResData is not the start address of section
ResData. What's wrong?
--------
Best Regards
PRC
May 12,2009