This is the mail archive of the 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]

[RFA:] Handle merge-sections in fixup_segment (Re: Various SH fixes)

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
> 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  <>
> 	* 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
  		       || bfd_is_com_section (add_symbol_segment)
+ 		       || (bfd_get_section_flags (stdoutput,
+ 						  add_symbol_segment)
+ 			   & SEC_MERGE) != 0

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. ;-)

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