linker behaviour for sections having flags SHF_MERGE/SHF_STRINGS
Alan Modra
amodra@gmail.com
Sat Nov 10 00:26:00 GMT 2012
On Fri, Nov 09, 2012 at 09:14:30AM -0800, shankarke@gmail.com wrote:
> $gold merge_test.o
> $ readelf -p 2 a.out
>
> String dump of section '.rodata':
> [ 0] abc
> [ 4] c
>
> Question :-
> Why is the difference ?
Possibly a gold bug.
> merge_test.s
> --------------
> .section .rodata.str,"aM","progbits",3
> .LC0:
> .asciz "abc"
> .LC1:
> .asciz "abc"
> .LC2:
> .asciz "cde"
> .LC3:
> .asciz "cde"
Your testcase is broken. With an entsize of 3, the elements are
abc,\0ab,c\0c,de\0,cde,\0
> .section .rodata.str,"aMS","progbits",2
> .LC0:
> .asciz "ab"
> .LC1:
> .asciz "ab"
Similarly here. The zero terminator should be entsize bytes wide.
> $gold merge_test.o
> gold: warning: merge_test.o: last entry in mergeable string section
> '.rodata.str' not null terminated
>
> $ld merge_test.o
> (no error)
And this is a ld bug. It should complain too. Nitpick on the gold
message: strings aren't null terminated, they are NUL terminated.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list