[PATCH, needs GWP] Add a BSF_SYNTHETIC flag
Richard Sandiford
rdsandiford@googlemail.com
Sat Jun 28 17:07:00 GMT 2008
More information about the Binutils mailing list
Sat Jun 28 17:07:00 GMT 2008
- Previous message (by thread): [PATCH 5/5] Defer allocation of R_MIPS_REL32 GOT slots
- Next message (by thread): [PATCH, needs GWP] Add a BSF_SYNTHETIC flag
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
BFD sometimes creates "synthetic" symbols to make disassembled code easier to understand. For example, it can create a "foo@plt" symbol for foo's PLT entry. These synthetic symbols do not have the full ELF information, so it is not safe to assume that every symbol in an ELF section has elf_symbol_type. This patch fixes one such assumption in the MIPS disassembler. It relies on a new BSF for synthetic symbols. Tested on mips64-linux-gnu and mips64el-linux-gnu. OK to install? Richard bfd/ * syms.c (BSF_SYNTHETIC): New flag. * elf.c (_bfd_elf_get_synthetic_symtab): Set it. * bfd-in.h (bfd_asymbol_flavour): Return bfd_target_unknown_flavour for synthetic symbols. * bfd-in2.h: Regenerate. opcodes/ * mips-dis.c (_print_insn_mips): Use bfd_asymbol_flavour to check for ELF symbols. Fix aliasing violation. Index: bfd/syms.c =================================================================== --- bfd/syms.c 2008-06-28 17:09:08.000000000 +0100 +++ bfd/syms.c 2008-06-28 17:14:51.000000000 +0100 @@ -297,6 +297,9 @@ typedef asymbol, symbol handling functio . with the expression tree serialized in the symbol name. *} .#define BSF_SRELC 0x100000 . +. {* This symbol was created by bfd_get_synthetic_symtab. *} +.#define BSF_SYNTHETIC 0x200000 +. . flagword flags; . . {* A pointer to the section to which this symbol is Index: bfd/elf.c =================================================================== --- bfd/elf.c 2008-06-28 17:09:08.000000000 +0100 +++ bfd/elf.c 2008-06-28 17:14:51.000000000 +0100 @@ -8786,6 +8786,7 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd we are defining a symbol, ensure one of them is set. */ if ((s->flags & BSF_LOCAL) == 0) s->flags |= BSF_GLOBAL; + s->flags |= BSF_SYNTHETIC; s->section = plt; s->value = addr - plt->vma; s->name = names; Index: bfd/bfd-in.h =================================================================== --- bfd/bfd-in.h 2008-06-28 17:09:08.000000000 +0100 +++ bfd/bfd-in.h 2008-06-28 17:14:51.000000000 +0100 @@ -231,7 +231,10 @@ #define bfd_asymbol_value(x) (bfd_asymbo #define bfd_asymbol_name(x) ((x)->name) /*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/ #define bfd_asymbol_bfd(x) ((x)->the_bfd) -#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour) +#define bfd_asymbol_flavour(x) \ + (((x)->flags & BSF_SYNTHETIC) != 0 \ + ? bfd_target_unknown_flavour \ + : bfd_asymbol_bfd (x)->xvec->flavour) /* A canonical archive symbol. */ /* This is a type pun with struct ranlib on purpose! */ Index: opcodes/mips-dis.c =================================================================== --- opcodes/mips-dis.c 2008-06-28 17:14:12.000000000 +0100 +++ opcodes/mips-dis.c 2008-06-28 17:14:51.000000000 +0100 @@ -2039,8 +2039,8 @@ _print_insn_mips (bfd_vma memaddr, #if SYMTAB_AVAILABLE if (info->mach == bfd_mach_mips16 - || (info->flavour == bfd_target_elf_flavour - && info->symbols != NULL + || (info->symbols != NULL + && bfd_asymbol_flavour (*info->symbols) == bfd_target_elf_flavour && ELF_ST_IS_MIPS16 ((*(elf_symbol_type **) info->symbols) ->internal_elf_sym.st_other))) return print_insn_mips16 (memaddr, info);
- Previous message (by thread): [PATCH 5/5] Defer allocation of R_MIPS_REL32 GOT slots
- Next message (by thread): [PATCH, needs GWP] Add a BSF_SYNTHETIC flag
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list