[PATCH, needs GWP] Add a BSF_SYNTHETIC flag
Richard Sandiford
rdsandiford@googlemail.com
Mon Jun 30 21:20:00 GMT 2008
More information about the Binutils mailing list
Mon Jun 30 21:20:00 GMT 2008
- Previous message (by thread): [PATCH, needs GWP] Add a BSF_SYNTHETIC flag
- Next message (by thread): [PATCH] Add MIPS_ELF_TDATA to elf_object_id.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Alan Modra <amodra@bigpond.net.au> writes: > On Sat, Jun 28, 2008 at 06:01:57PM +0100, Richard Sandiford wrote: >> 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. > > OK. Patch to set BSF_SYNTHETIC on synthetic syms created in > elf32-ppc.c and elf64-ppc.c preapproved. (Or leave it to me if you > like..) Oops, thanks for the gentle heads-up ;) Here's what I installed after testing on powerpc-linux-gnu and powerpc64-linux-gnu. Richard bfd/ * syms.c (BSF_SYNTHETIC): New flag. * elf.c (_bfd_elf_get_synthetic_symtab): Set it. * elf32-ppc.c (ppc_elf_get_synthetic_symtab): Likewise. * elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Likewise. * 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. Index: bfd/syms.c =================================================================== --- bfd/syms.c 21 Sep 2007 07:58:03 -0000 1.46 +++ bfd/syms.c 30 Jun 2008 20:47:28 -0000 @@ -297,6 +297,9 @@ CODE_FRAGMENT . 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 4 Jun 2008 14:24:05 -0000 1.448 +++ bfd/elf.c 30 Jun 2008 20:47:29 -0000 @@ -8785,6 +8785,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/elf32-ppc.c =================================================================== --- bfd/elf32-ppc.c 14 May 2008 16:00:38 -0000 1.238 +++ bfd/elf32-ppc.c 30 Jun 2008 20:47:30 -0000 @@ -2450,6 +2450,7 @@ ppc_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 = glink; s->value = stub_vma - glink->vma; s->name = names; @@ -2466,7 +2467,7 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, /* Add a symbol at the start of the glink branch table. */ memset (s, 0, sizeof *s); s->the_bfd = abfd; - s->flags = BSF_GLOBAL; + s->flags = BSF_GLOBAL | BSF_SYNTHETIC; s->section = glink; s->value = glink_vma - glink->vma; s->name = names; @@ -2480,7 +2481,7 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, /* Add a symbol for the glink PLT resolver. */ memset (s, 0, sizeof *s); s->the_bfd = abfd; - s->flags = BSF_GLOBAL; + s->flags = BSF_GLOBAL | BSF_SYNTHETIC; s->section = glink; s->value = resolv_vma - glink->vma; s->name = names; Index: bfd/elf64-ppc.c =================================================================== --- bfd/elf64-ppc.c 5 Jun 2008 00:30:09 -0000 1.283 +++ bfd/elf64-ppc.c 30 Jun 2008 20:47:31 -0000 @@ -2954,6 +2954,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abf size_t len; *s = *syms[i]; + s->flags |= BSF_SYNTHETIC; s->section = sym->section; s->value = sym->value + r->addend; s->name = names; @@ -3124,6 +3125,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abf if ((sec->flags & SEC_CODE) != 0) s->section = sec; } + s->flags |= BSF_SYNTHETIC; s->value = ent - s->section->vma; s->name = names; *names++ = '.'; @@ -3145,7 +3147,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abf /* Add a symbol for the main glink trampoline. */ memset (s, 0, sizeof *s); s->the_bfd = abfd; - s->flags = BSF_GLOBAL; + s->flags = BSF_GLOBAL | BSF_SYNTHETIC; s->section = glink; s->value = resolv_vma - glink->vma; s->name = names; @@ -3181,6 +3183,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abf 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 = glink; s->value = glink_vma - glink->vma; s->name = names; Index: bfd/bfd-in.h =================================================================== --- bfd/bfd-in.h 21 May 2008 12:01:36 -0000 1.136 +++ bfd/bfd-in.h 30 Jun 2008 20:47:29 -0000 @@ -231,7 +231,10 @@ typedef const struct reloc_howto_struct #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: bfd/bfd-in2.h =================================================================== --- bfd/bfd-in2.h 21 May 2008 12:01:36 -0000 1.446 +++ bfd/bfd-in2.h 30 Jun 2008 20:47:30 -0000 @@ -238,7 +238,10 @@ typedef const struct reloc_howto_struct #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! */ @@ -4502,6 +4505,9 @@ typedef struct bfd_symbol 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: opcodes/mips-dis.c =================================================================== --- opcodes/mips-dis.c 12 Jun 2008 21:44:54 -0000 1.72 +++ opcodes/mips-dis.c 30 Jun 2008 20:47:31 -0000 @@ -2066,8 +2066,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_symbol_type **) info->symbols)->internal_elf_sym.st_other == STO_MIPS16))) return print_insn_mips16 (memaddr, info);
- Previous message (by thread): [PATCH, needs GWP] Add a BSF_SYNTHETIC flag
- Next message (by thread): [PATCH] Add MIPS_ELF_TDATA to elf_object_id.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list