This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: mn10300: relaxing vs section merging
Ok, here is my latest patch. This one I tested with gcc's C
testsuite, with and without -mrelax, with no failures with that
weren't also without:
Index: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/uberbaum/./bfd/elf-m10300.c,v
retrieving revision 1.51
diff -p -C2 -r1.51 bfd/elf-m10300.c
*** bfd/elf-m10300.c 27 May 2004 06:22:54 -0000 1.51
--- bfd/elf-m10300.c 27 May 2004 23:12:07 -0000
*************** mn10300_elf_relax_section (abfd, sec, li
*** 2463,2466 ****
--- 2463,2467 ----
const char *sym_name;
char *new_name;
+ bfd_vma saved_addend;
/* A local symbol. */
*************** mn10300_elf_relax_section (abfd, sec, li
*** 2475,2485 ****
sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
- symval = (isym->st_value
- + sym_sec->output_section->vma
- + sym_sec->output_offset);
sym_name = bfd_elf_string_from_elf_section (abfd,
symtab_hdr->sh_link,
isym->st_name);
/* Tack on an ID so we can uniquely identify this
local symbol in the global hash table. */
--- 2476,2498 ----
sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
sym_name = bfd_elf_string_from_elf_section (abfd,
symtab_hdr->sh_link,
isym->st_name);
+ if ((sym_sec->flags & SEC_MERGE)
+ && ELF_ST_TYPE (isym->st_info) == STT_SECTION
+ && sym_sec->sec_info_type == ELF_INFO_TYPE_MERGE)
+ {
+ 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;
+ }
+ else
+ {
+ symval = (isym->st_value
+ + sym_sec->output_section->vma
+ + sym_sec->output_offset);
+ }
/* Tack on an ID so we can uniquely identify this
local symbol in the global hash table. */
Index: gas/config/tc-mn10300.c
===================================================================
RCS file: /cvs/uberbaum/./gas/config/tc-mn10300.c,v
retrieving revision 1.46
diff -p -C2 -r1.46 gas/config/tc-mn10300.c
*** gas/config/tc-mn10300.c 6 May 2004 11:01:48 -0000 1.46
--- gas/config/tc-mn10300.c 27 May 2004 23:12:08 -0000
*************** mn10300_fix_adjustable (fixp)
*** 2543,2546 ****
--- 2543,2553 ----
return 0;
+ /* Likewise, do not adjust symbols that won't be merged, or debug
+ symbols, because they too break relaxation. We do want to adjust */
+ if (! (S_GET_SEGMENT(fixp->fx_addsy)->flags & SEC_MERGE))
+ return 0;
+ if (strncmp (S_GET_SEGMENT (fixp->fx_addsy)->name, ".debug", 6) == 0)
+ return 0;
+
return 1;
}
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 gas/config/tc-mn10300.h
*** gas/config/tc-mn10300.h 10 Jul 2003 04:44:56 -0000 1.14
--- gas/config/tc-mn10300.h 27 May 2004 23:12:08 -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 *));