Re: [PATCH] libebl: Do not require EI_OSABI for IFUNC.
On 11/24/22 13:33, Mark Wielaard wrote: > Hi Martin, > > On Thu, 2022-11-24 at 13:23 +0100, Martin Liška wrote: >> Similar fix to: >> https://sourceware.org/bugzilla/show_bug.cgi?id=29718 >> >> Ready for master? > > Assuming runtime, glibc/ld.so, accepts this without EI_OSABI set to > ELFOSABI_LINUX, it seems ok to print it as GNU_IFUNC. > >>else if (symbol == STT_GNU_IFUNC >> && ebl != NULL >> - && (ident = elf_getident (ebl->elf, NULL)) != NULL >> - && ident[EI_OSABI] == ELFOSABI_LINUX) >> -return "GNU_IFUNC"; >> + && (ident = elf_getident (ebl->elf, NULL)) != NULL) >> +return "GNU_IFUNC"; /* Ignore EI_OSABI >> + as STT_GNU_IFUNC is a reserved name. */ > > Note that you technically also don't need the elf_getident call > anymore, except as sanity check that the ELF header can be read > properly. > > OK, with and without that change. Sorry, I decided to scratch this as it violates the standard: https://sourceware.org/bugzilla/show_bug.cgi?id=29718#c6 Cheers, Martin > > Cheers, > > Mark
[PATCH] readelf: print warning for -sW
The option -s accepts in elfutils (compared to binutils) a positional argument that is name of a symbol table section which should be printed. Thus, print a reasonable warning if -sW is used: ./src/readelf -sW a.out WARNING: cannot find section: 'W' Ready for master? Thanks, Martin src/ChangeLog: * readelf.c (print_symtab): Change signature and return true if something is printed. (process_elf_file): Use it and print warning. tests/ChangeLog: * run-readelf-s.sh: Test -sW. --- src/readelf.c | 23 ++- tests/run-readelf-s.sh | 3 +++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/readelf.c b/src/readelf.c index 3dafb041..cc3e0229 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -306,7 +306,7 @@ static void handle_relocs_rel (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr); static void handle_relocs_rela (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr); -static void print_symtab (Ebl *ebl, int type); +static bool print_symtab (Ebl *ebl, int type); static void handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr); static void print_verinfo (Ebl *ebl); static void handle_verneed (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr); @@ -1022,6 +1022,8 @@ process_elf_file (Dwfl_Module *dwflmod, int fd) goto ebl_error; } + bool symtab_printed = false; + if (print_file_header) print_ehdr (ebl, ehdr); if (print_section_header) @@ -1037,11 +1039,17 @@ process_elf_file (Dwfl_Module *dwflmod, int fd) if (print_histogram) handle_hash (ebl); if (print_symbol_table || print_dynsym_table) -print_symtab (ebl, SHT_DYNSYM); +symtab_printed |= print_symtab (ebl, SHT_DYNSYM); if (print_version_info) print_verinfo (ebl); if (print_symbol_table) -print_symtab (ebl, SHT_SYMTAB); +symtab_printed |= print_symtab (ebl, SHT_SYMTAB); + + if ((print_symbol_table || print_dynsym_table) + && !symtab_printed && symbol_table_section != NULL) +printf ("WARNING: %s: '%s'\n", _("cannot find section"), +symbol_table_section); + if (print_arch) print_liblist (ebl); if (print_arch) @@ -2425,13 +2433,15 @@ handle_relocs_rela (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr) } -/* Print the program header. */ -static void +/* Print the program header. Return true if a symtab is printed, + false otherwise. */ +static bool print_symtab (Ebl *ebl, int type) { /* Find the symbol table(s). For this we have to search through the section table. */ Elf_Scn *scn = NULL; + bool symtab_printed = false; while ((scn = elf_nextscn (ebl->elf, scn)) != NULL) { @@ -2467,8 +2477,11 @@ print_symtab (Ebl *ebl, int type) elf_ndxscn (scn), elf_errmsg (-1)); } handle_symtab (ebl, scn, shdr); + symtab_printed = true; } } + + return symtab_printed; } diff --git a/tests/run-readelf-s.sh b/tests/run-readelf-s.sh index ee1c0e82..c150c165 100755 --- a/tests/run-readelf-s.sh +++ b/tests/run-readelf-s.sh @@ -395,4 +395,7 @@ Symbol table [27] '.symtab' contains 42 entries: 41: 004003a8 0 FUNCGLOBAL DEFAULT 11 _init EOF +${abs_top_builddir}/src/readelf --elf-section -sW testfilebaxmin 2>&1 \ + | grep "WARNING: cannot find section: 'W'" >/dev/null || exit 2 + exit 0 -- 2.38.1
[Bug tools/29719] eu-readelf -s=section is confusing
https://sourceware.org/bugzilla/show_bug.cgi?id=29719 Martin Liska changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at sourceware dot org |mliska at suse dot cz --- Comment #4 from Martin Liska --- I finished the patch: https://sourceware.org/pipermail/elfutils-devel/2022q4/005607.html -- You are receiving this mail because: You are on the CC list for the bug.
Re: [PATCH RFC] backends: Add RISC-V object attribute printing
On 10/13/22 16:53, Mark Wielaard wrote: > Hi Andreas, > > On Wed, 2022-08-10 at 11:27 +0200, Andreas Schwab via Elfutils-devel > wrote: >> This does not work yet. The RISC-V attribute tags use the same >> convention as the GNU attributes: odd numbered tags take a string >> value, >> even numbered ones an integer value, but print_attributes assumes the >> ARM numbering scheme by default for non-GNU attributes. > > Yeah, I see this comment in print_attributes: > > /* GNU style tags have either a uleb128 value, > when lowest bit is not set, or a string > when the lowest bit is set. > "compatibility" (32) is special. It has > both a string and a uleb128 value. For > non-gnu we assume 6 till 31 only take ints. > XXX see arm backend, do we need a separate > hook? */ > > Maybe we need a flag in the backend to tell whether attributes follow > the "gnu_vendor" convention? So that could be checked at: > > bool gnu_vendor = (q - name == sizeof "gnu" > && !memcmp (name, "gnu", sizeof "gnu")); > gnu_vendor |= ebl->has_gnu_attributes; > > Or something similar? Andreas: Can you please take a look at this? Martin > > Cheers, > > Mark
Re: [PATCH] readelf: print warning for -sW
Hi Marin, On Fri, 2022-11-25 at 14:29 +0100, Martin Liška wrote: > The option -s accepts in elfutils (compared to binutils) a positional > argument that is name of a symbol table section which should be > printed. > > Thus, print a reasonable warning if -sW is used: > ./src/readelf -sW a.out > WARNING: cannot find section: 'W' > > Ready for master? Looks good. But one nitpick below. > src/ChangeLog: > > * readelf.c (print_symtab): Change signature and return true if > something is printed. > (process_elf_file): Use it and print warning. Aha, we are processing the symbol sections twice, once for SHT_DYNSYM, then for SHT_SYMTAB. And the named section should be one or the other. Good. > tests/ChangeLog: > > * run-readelf-s.sh: Test -sW. Plus a new testcase. Perfect.. > diff --git a/tests/run-readelf-s.sh b/tests/run-readelf-s.sh > index ee1c0e82..c150c165 100755 > --- a/tests/run-readelf-s.sh > +++ b/tests/run-readelf-s.sh > @@ -395,4 +395,7 @@ Symbol table [27] '.symtab' contains 42 entries: > 41: 004003a8 0 FUNCGLOBAL DEFAULT 11 _init > EOF > > +${abs_top_builddir}/src/readelf --elf-section -sW testfilebaxmin 2>&1 \ > + | grep "WARNING: cannot find section: 'W'" >/dev/null || exit 2 > + You need to run a tests with testrun or testrun_compare so they actually run against the just build libraries (and so they run under valgrind when configured with --enable-valgrind). So in this case just add a testrun in front. -${abs_top_builddir}/src/readelf --elf-section -sW testfilebaxmin 2>&1 \ +testrun ${abs_top_builddir}/src/readelf --elf-section -sW testfilebaxmin 2>&1 \ OK with that change. Thanks, Mark