From 60982e6e9da662cf5c9d12c6d095738a9b2dcf68 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 5 Apr 2008 00:40:51 +0000 Subject: [PATCH] 0.134 items --- NEWS | 6 ++++++ backends/ChangeLog | 5 +++++ backends/alpha_init.c | 1 + backends/alpha_symbol.c | 46 ++++++++++++++++++++++++++++++++++++++++- backends/sparc_symbol.c | 1 - 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 2c644dc86..ba4c3be7e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +Version 0.134: + +elflint: backend improvements for sparc, alpha + +libdwfl, libelf: bug fixes + Version 0.133: readelf, elflint, libebl: SHT_GNU_ATTRIBUTE section handling (readelf -A) diff --git a/backends/ChangeLog b/backends/ChangeLog index c72c23841..06e9041f8 100644 --- a/backends/ChangeLog +++ b/backends/ChangeLog @@ -1,3 +1,8 @@ +2008-04-04 Roland McGrath + + * alpha_symbol.c (alpha_check_special_section): New function. + * alpha_init.c (alpha_init): Initialize check_special_section hook. + 2008-03-31 Roland McGrath * sparc_symbol.c (sparc_symbol_type_name): New function. diff --git a/backends/alpha_init.c b/backends/alpha_init.c index 3c9e29d2b..1ca99abc5 100644 --- a/backends/alpha_init.c +++ b/backends/alpha_init.c @@ -55,6 +55,7 @@ alpha_init (elf, machine, eh, ehlen) HOOK (eh, reloc_simple_type); HOOK (eh, return_value_location); HOOK (eh, machine_section_flag_check); + HOOK (eh, check_special_section); HOOK (eh, register_info); HOOK (eh, core_note); HOOK (eh, auxv_info); diff --git a/backends/alpha_symbol.c b/backends/alpha_symbol.c index dc3cce569..aa45c61ee 100644 --- a/backends/alpha_symbol.c +++ b/backends/alpha_symbol.c @@ -1,5 +1,5 @@ /* Alpha specific symbolic name handling. - Copyright (C) 2002, 2005, 2007 Red Hat, Inc. + Copyright (C) 2002,2005,2007,2008 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper , 2002. @@ -77,3 +77,47 @@ alpha_machine_section_flag_check (GElf_Xword sh_flags) { return (sh_flags &~ (SHF_ALPHA_GPREL)) == 0; } + +bool +alpha_check_special_section (Ebl *ebl, + int ndx __attribute__ ((unused)), + const GElf_Shdr *shdr, + const char *sname __attribute__ ((unused))) +{ + if ((shdr->sh_flags + & (SHF_WRITE | SHF_EXECINSTR)) == (SHF_WRITE | SHF_EXECINSTR) + && shdr->sh_addr != 0) + { + /* This is ordinarily flagged, but is valid for an old-style PLT. + + Look for the SHT_DYNAMIC section and the DT_PLTGOT tag in it. + Its d_ptr should match the .plt section's sh_addr. */ + + Elf_Scn *scn = NULL; + while ((scn = elf_nextscn (ebl->elf, scn)) != NULL) + { + GElf_Shdr scn_shdr; + if (likely (gelf_getshdr (scn, &scn_shdr) != NULL) + && scn_shdr.sh_type == SHT_DYNAMIC + && scn_shdr.sh_entsize != 0) + { + GElf_Addr pltgot = 0; + Elf_Data *data = elf_getdata (scn, NULL); + if (data != NULL) + for (size_t i = 0; i < data->d_size / scn_shdr.sh_entsize; ++i) + { + GElf_Dyn dyn; + if (unlikely (gelf_getdyn (data, i, &dyn) == NULL)) + break; + if (dyn.d_tag == DT_PLTGOT) + pltgot = dyn.d_un.d_ptr; + else if (dyn.d_tag == DT_ALPHA_PLTRO && dyn.d_un.d_val != 0) + return false; /* This PLT should not be writable. */ + } + return pltgot == shdr->sh_addr; + } + } + } + + return false; +} diff --git a/backends/sparc_symbol.c b/backends/sparc_symbol.c index 27de54c04..7896e9f46 100644 --- a/backends/sparc_symbol.c +++ b/backends/sparc_symbol.c @@ -73,7 +73,6 @@ sparc_check_special_section (Ebl *ebl, const GElf_Shdr *shdr, const char *sname __attribute__ ((unused))) { - ebl=ebl; if ((shdr->sh_flags & (SHF_WRITE | SHF_EXECINSTR)) == (SHF_WRITE | SHF_EXECINSTR)) { -- 2.47.2