This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[RFA:] Handle merge-sections in fixup_segment (Re: Various SH fixes)
- To: <binutils at sources dot redhat dot com>
- Subject: [RFA:] Handle merge-sections in fixup_segment (Re: Various SH fixes)
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- Date: Sun, 14 Oct 2001 21:16:13 -0400 (EDT)
- cc: kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
On Sun, 23 Sep 2001, kaz Kojima wrote:
> I've tried to bootstrap current GCC (3.1 CVS) using binutils in
> CVS and your patch in
> http://sources.redhat.com/ml/binutils/2001-09/msg00302.html
> and found a new problem of SH assembler for a merge section.
In the future, please use a new subject for a new bug-report.
> A testcase is the following foo.s:
>
> .section .rodata.str.1, "aMS", @progbits, 1
> LC0:
> .string "string0"
> .align 2
> .section .rodata.str.1, "aMS", @progbits, 1
> LC1:
> .string "string1"
> .align 2
> .text
> .align 2
> L0:
> .long LC0
> L1:
> .long LC1
>
> The binary got by as -o foo.o foo.s and ld -o foo foo.o has a wrong
> reference which should be LC1. objdump -s shows
>
> Contents of section .text:
> 400074 0040007c 0040008c
>
> but nm reports
>
> 0040007c r LC0
> 00400084 r LC1
>
> and it seems the problem is inplace value of the reloc for L1 in
> foo.o generated by as.
> 2001-09-23 kaz Kojima <kkojima@rr.iij4u.or.jp>
>
> * config/tc-sh.c (md_apply_fix): Adjust back VAL for a symbol in
> a merge section.
There's a bug allright, though I don't think that's the right
place to fix it.
I would have fixed it by letting TC_FIX_ADJUSTABLE return zero
for it, but that would imply that it's up to each *port* to do
the same thing. Though it seems it only makes a difference for
ports with the "kitten-eating wrong" (RTH's judgement :-) RELA
with partial-inplace.
When reading the SEC_MERGE patches, it seems it was supposed to
be the generic bits of gas that should handle it: to treat
relocations for SEC_MERGE section in a matter similar to
external references, so the linker can do whatever it likes with
the section contents. Therefore, there should be no resolved
addend for the fx_addsy, just as if TC_FIX_ADJUSTABLE had
returned 1 or the symbol had been undefined at assembly-time.
I'm deliberately not looking into handling subtracted symbols,
I'm just leaving that as is.
Ok to commit? No new test-failures for sh-elf, sh-linux,
i686-pc-linux-gnulibc1, cris-elf with this patch.
* write.c (fixup_segment): Handle fixups for SEC_MERGE sections as
for undefined symbols.
Index: write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.46
diff -p -c -r1.46 write.c
*** write.c 2001/09/18 10:08:14 1.46
--- write.c 2001/10/15 00:52:22
*************** fixup_segment (fixP, this_segment_type)
*** 2810,2815 ****
--- 2810,2818 ----
else if (add_symbol_segment == undefined_section
#ifdef BFD_ASSEMBLER
|| bfd_is_com_section (add_symbol_segment)
+ || (bfd_get_section_flags (stdoutput,
+ add_symbol_segment)
+ & SEC_MERGE) != 0
#endif
)
{
brgds, H-P
PS. To whomever: I'll get to the other SH bug reports soon, and
after that I might dare reminding Nick & Co. about the MMIX port. ;-)