This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
mn10300: relaxing vs section merging
- From: DJ Delorie <dj at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 5 May 2004 14:18:44 -0400
- Subject: mn10300: relaxing vs section merging
There are problems with the mn10300 when you turn on both relaxing and
section merging. What happens is, the relaxing code uses the
pre-merged symbol offsets. I finally figured out why the obvious
solution didn't work, and now have a patch. However, before I
consider applying it, I have a question: why don't we bother adjusting
relocs in gas? You have to use section-relative relocs with section
merging, but I couldn't find any explanation of why the call to do so
was commented out.
2004-05-05 DJ Delorie <dj@redhat.com>
* config/tc-mn10300.h (tc_fix_adjustable): Enable so we get
section-relative symbols.
* elf-m10300.c (mn10300_elf_relax_section): Preserve reloc
addend so it doesn't get adjusted twice, but do use merged
value when calculating symbol value.
Index: gas/config/tc-mn10300.h
===================================================================
RCS file: /cvs/uberbaum/./gas/config/tc-mn10300.h,v
retrieving revision 1.14
diff -p -C2 -r1.14 tc-mn10300.h
*** gas/config/tc-mn10300.h 10 Jul 2003 04:44:56 -0000 1.14
--- gas/config/tc-mn10300.h 5 May 2004 18:12:29 -0000
*************** void mn10300_cons_fix_new PARAMS ((fragS
*** 103,108 ****
/* Don't bother to adjust relocs. */
! #define tc_fix_adjustable(FIX) 0
! /* #define tc_fix_adjustable(FIX) mn10300_fix_adjustable (FIX) */
extern bfd_boolean mn10300_fix_adjustable PARAMS ((struct fix *));
--- 103,108 ----
/* Don't bother to adjust relocs. */
! /* #define tc_fix_adjustable(FIX) 0 */
! #define tc_fix_adjustable(FIX) mn10300_fix_adjustable (FIX)
extern bfd_boolean mn10300_fix_adjustable PARAMS ((struct fix *));
Index: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/uberbaum/./bfd/elf-m10300.c,v
retrieving revision 1.49
diff -p -C2 -r1.49 elf-m10300.c
*** bfd/elf-m10300.c 27 Mar 2004 10:58:05 -0000 1.49
--- bfd/elf-m10300.c 5 May 2004 18:12:31 -0000
*************** mn10300_elf_relax_section (abfd, sec, li
*** 2440,2443 ****
--- 2440,2444 ----
const char *sym_name;
char *new_name;
+ bfd_vma saved_addend;
/* A local symbol. */
*************** mn10300_elf_relax_section (abfd, sec, li
*** 2459,2462 ****
--- 2460,2467 ----
isym->st_name);
+ saved_addend = irel->r_addend;
+ symval = _bfd_elf_rela_local_sym (abfd, isym, &sym_sec, irel);
+ symval += irel->r_addend;
+ irel->r_addend = saved_addend;
/* Tack on an ID so we can uniquely identify this
local symbol in the global hash table. */