diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2004-02-09 08:04:00 +0000 |
---|---|---|
committer | Richard Sandiford <rdsandiford@googlemail.com> | 2004-02-09 08:04:00 +0000 |
commit | 174fd7f9556183397625dbfa99ef68ecd325c74b (patch) | |
tree | 0343a185c2e517f52888f5d2fb8e11af23d036b7 | |
parent | edfae06341a087244f28127674aba54f20912885 (diff) | |
download | gdb-174fd7f9556183397625dbfa99ef68ecd325c74b.zip gdb-174fd7f9556183397625dbfa99ef68ecd325c74b.tar.gz gdb-174fd7f9556183397625dbfa99ef68ecd325c74b.tar.bz2 |
* bfd-elf.h (elf_backend_name_local_section_symbols): New hook.
* elf.c (swap_out_syms): Use it to decide whether local section
symbols should be named.
* elfxx-target.h (elf_backend_name_local_section_symbols): New macro.
* elfxx-mips.h (_bfd_mips_elf_name_local_section_symbols): Declare.
(elf_backend_name_local_section_symbols): Define.
* elfxx-mips.c (_bfd_mips_elf_name_local_section_symbols): New.
-rw-r--r-- | bfd/ChangeLog | 10 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 5 | ||||
-rw-r--r-- | bfd/elf.c | 8 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 20 | ||||
-rw-r--r-- | bfd/elfxx-mips.h | 4 | ||||
-rw-r--r-- | bfd/elfxx-target.h | 4 |
6 files changed, 50 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 72a2e2f..19b521c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +2004-02-09 Richard Sandiford <rsandifo@redhat.com> + + * bfd-elf.h (elf_backend_name_local_section_symbols): New hook. + * elf.c (swap_out_syms): Use it to decide whether local section + symbols should be named. + * elfxx-target.h (elf_backend_name_local_section_symbols): New macro. + * elfxx-mips.h (_bfd_mips_elf_name_local_section_symbols): Declare. + (elf_backend_name_local_section_symbols): Define. + * elfxx-mips.c (_bfd_mips_elf_name_local_section_symbols): New. + 2004-01-30 H.J. Lu <hongjiu.lu@intel.com> * elfxx-ia64.c (elfNN_ia64_relax_brl): New function. diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index c457a39..6bbacad 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -576,6 +576,11 @@ struct elf_backend_data int (*elf_backend_get_symbol_type) (Elf_Internal_Sym *, int); + /* Return true if local section symbols should have a non-null st_name. + NULL implies false. */ + bfd_boolean (*elf_backend_name_local_section_symbols) + (bfd *); + /* A function to do additional processing on the ELF section header just before writing it out. This is used to set the flags and type fields for some sections, or to actually write out data for @@ -5261,6 +5261,7 @@ swap_out_syms (bfd *abfd, char *outbound_shndx; int idx; bfd_size_type amt; + bfd_boolean name_local_sections; if (!elf_map_symbols (abfd)) return FALSE; @@ -5326,6 +5327,10 @@ swap_out_syms (bfd *abfd, outbound_shndx += sizeof (Elf_External_Sym_Shndx); } + name_local_sections + = (bed->elf_backend_name_local_section_symbols + && bed->elf_backend_name_local_section_symbols (abfd)); + syms = bfd_get_outsymbols (abfd); for (idx = 0; idx < symcount; idx++) { @@ -5335,7 +5340,8 @@ swap_out_syms (bfd *abfd, flagword flags = syms[idx]->flags; int type; - if ((flags & (BSF_SECTION_SYM | BSF_GLOBAL)) == BSF_SECTION_SYM) + if (!name_local_sections + && (flags & (BSF_SECTION_SYM | BSF_GLOBAL)) == BSF_SECTION_SYM) { /* Local section symbols have no name. */ sym.st_name = 0; diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 7bcdb11..a296458 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -4271,6 +4271,26 @@ _bfd_mips_elf_symbol_processing (bfd *abfd, asymbol *asym) } } +/* There appears to be a bug in the MIPSpro linker that causes GOT_DISP + relocations against two unnamed section symbols to resolve to the + same address. For example, if we have code like: + + lw $4,%got_disp(.data)($gp) + lw $25,%got_disp(.text)($gp) + jalr $25 + + then the linker will resolve both relocations to .data and the program + will jump there rather than to .text. + + We can work around this problem by giving names to local section symbols. + This is also what the MIPSpro tools do. */ + +bfd_boolean +_bfd_mips_elf_name_local_section_symbols (bfd *abfd) +{ + return SGI_COMPAT (abfd); +} + /* Work over a section just before writing it out. This routine is used by both the 32-bit and the 64-bit ABI. FIXME: We recognize sections that need the SHF_MIPS_GPREL flag by name; there has to be diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h index d3787e9..9e5d7af 100644 --- a/bfd/elfxx-mips.h +++ b/bfd/elfxx-mips.h @@ -24,6 +24,8 @@ extern bfd_boolean _bfd_mips_elf_new_section_hook (bfd *, asection *); extern void _bfd_mips_elf_symbol_processing (bfd *, asymbol *); +extern bfd_boolean _bfd_mips_elf_name_local_section_symbols + (bfd *); extern bfd_boolean _bfd_mips_elf_section_processing (bfd *, Elf_Internal_Shdr *); extern bfd_boolean _bfd_mips_elf_section_from_shdr @@ -119,4 +121,6 @@ extern bfd_vma _bfd_mips_elf_sign_extend (bfd_vma, int); extern struct bfd_elf_special_section const _bfd_mips_elf_special_sections[]; +#define elf_backend_name_local_section_symbols \ + _bfd_mips_elf_name_local_section_symbols #define elf_backend_special_sections _bfd_mips_elf_special_sections diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 40fe8e7..ca0e47b 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -274,6 +274,9 @@ #ifndef elf_backend_get_symbol_type #define elf_backend_get_symbol_type 0 #endif +#ifndef elf_backend_name_local_section_symbols +#define elf_backend_name_local_section_symbols 0 +#endif #ifndef elf_backend_section_processing #define elf_backend_section_processing 0 #endif @@ -456,6 +459,7 @@ static const struct elf_backend_data elfNN_bed = elf_backend_symbol_processing, elf_backend_symbol_table_processing, elf_backend_get_symbol_type, + elf_backend_name_local_section_symbols, elf_backend_section_processing, elf_backend_section_from_shdr, elf_backend_section_flags, |