Re: [PATCH] nm: Explicitly print weak 'V' or 'T' and common 'C' symbols.
On Sun, 2020-06-07 at 01:12 +0200, Mark Wielaard wrote: > Mimic binutils nm for bsd and posix formats which uses 'V' for weak > symbols, 'C' for common symbols and 'T' for weak functions. Also fix > some formatting issues. Don't print undefined addresses as zeros, but > make sure there is enough padding instead. Just print UNIQUE for > GNU_UNIQUE to make it fit 6 chars, like other binding names in sysv > format. Pushed to master.
[Bug general/25227] "eu-nm --extern" skips first symbol
https://sourceware.org/bugzilla/show_bug.cgi?id=25227 Mark Wielaard changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #11 from Mark Wielaard --- commit 76ff94dce7ee8dd88c502bc0bbfc8dea15efea5b Author: Mark Wielaard Date: Sun Jun 7 01:02:52 2020 +0200 nm: Explicitly print weak 'V' or 'T' and common 'C' symbols. Mimic binutils nm for bsd and posix formats which uses 'V' for weak symbols, 'C' for common symbols and 'T' for weak functions. Also fix some formatting issues. Don't print undefined addresses as zeros, but make sure there is enough padding instead. Just print UNIQUE for GNU_UNIQUE to make it fit 6 chars, like other binding names in sysv format. https://sourceware.org/bugzilla/show_bug.cgi?id=25227 Signed-off-by: Mark Wielaard -- You are receiving this mail because: You are on the CC list for the bug.
Re: [PATCH] nm: Handle corrupt symbol name table.
On Sun, 2020-06-07 at 16:51 +0200, Mark Wielaard wrote: > We try to sort symbol by name (when neither -n nor -p are given). > This could crash if the symbol name table was corrupt. Use elf_strptr > to get the symbol name and use the empty string in case a name > couldn't be found. Pushed to master.
Re: location list
Hi Sasha, On Tue, 2020-06-09 at 16:38 +, Sasha Da Rocha Pinheiro via Elfutils-devel wrote: > I am now trying to design the changes needed to be done in Dyninst. > So far we have only used the functions dwarf_* under libdw. > What I understood is that libdw is kinda divided in subsets of functions, > dwarf_*, dwfl_* and dwelf_*. > I didn't find any documentation about it, or the purpose of these subset of > functions. > (Whats fl in dwfl for?) > But my understanding is that I can't use data structures from one on the > other one. > That alone will need some design to modify the way we parse dwarf info into > Dyninst. > Currently the lifetime of a dwarf handle lasts through one execution, > because we parse dwarf data when the user needs it. So elfutils contains 4 libraries. libelf, which is a semi-standardize "unix" library to read and manipulate ELF files. libdw, which adds reading of DWARF data, linux process and kernel mappings, and various elf/dwarf utility functions. libasm, which provides a assembler and disassembler interface, but which isn't really finished/recommended at the moment (it only provides a partial x86 assembler/disassembler and a bpf disassembler). And libdebuginfod, which provides a way to fetch remotely stored executables, debuginfo and sources based on build-ids (from a debuginfod server). There used to be non-public, internal, "libebl" backend libraries, for each elfutils supported architecture (libebl_aarch64.so, libebl_riscv.so, etc.) which were loaded dynamically to safe a bit of memory in case the backend/arch wasn't used. But with 0.178 the libraries are build into libdw.so directly and no longer dynamically loaded. libebl was never intended to be used directly. [lib]ebl stands for ELF Backend Library. [lib]dw is short for DWARF. [lib]dwfl then can be read as DWARF Frontend library functions. And [lib]dwelf are the DWARF and ELF utility functions. The main data structure of libelf is the Elf handle which can be used to go through an ELF through sections (Shdrs) or program (Phdrs) headers. The main data structure that the libdw dwarf_* functions work on is the Dwarf handle, which is associated with one Elf handle. The main data structure of the libdwfl dwfl_* functions is the Dwfl handle. A Dwfl represents a program (or kernel) with library (or kernel modules) memory lay out. Each Dwfl_Module represents a piece of executable code mapped at a certain memory range. The Dwfl uses buildids to associate/create Elf images and Dwarf handles associated with each Dwfl_Module (it can optionally use libdebuginfod to download/cache any it doesn't have yet). Since kernel modules are ET_REL file (non-relocated object files), libdwfl also resolves any relocations between .debug_sections (this is the property we abused in the example code I gave you, where we construct a Dwfl from a single ET_REL object file). Given a Dwfl_Module you can get the associated Elf or Dwarf with dwfl_module_getelf or dwfl_module_getdwarf. You will note that those functions also provide a Dwarf_Addr bias which might be non- zero if the address range where the Dwfl_Module is mapped is different (at an offset) from the addresses found in the Elf image or Dwarf data. You would use the libdwfl functions if you want to represent a whole program as it would be mapped into memory (or the kernel and its modules). It is convenient if you got a process map (dwfl_linux_proc_report) or core file (dwfl_core_file_report). The libdwfl functions would automatically associate an Elf image and find the Dwarf data for you. It is even nice to use for "single file" programs like we did in the example with the single file because it does the automatic lookup of the Dwarf handle, and because, if the file is an ET_REL object, you get the relocation between .debug sections for free. It might make sense to provide utility functions (in libdwelf) to do both functions separately from setting up a Dwfl. You can already do most of the lookups by hand using dwelf_elf_gnu_debuglink, dwelf_dwarf_gnu_debugaltlink, dwelf_elf_gnu_build_id, plus the libdebuginfod calls. But one generic helper function might be convenient. The only other way to do the relocation resolving at the moment is through eu-strip --reloc-debug-sections-only (but this is a permanent, non-reversible operation on the file, which will make it unsuitable for linking with other object files). Hope that give a bit of an overview. Cheers, Mark
[COMMITTED] libebl: Remove Ebl struct size check and MODVERSION string.
We used to do several sanity checks when the ebl backend libraries were loaded to make sure there was no version mismatch. When initializing the backend we passed the current Ebl struct size so the library could check it supported the given Ebl struct and we checked that the init method returned the correct build time module version string. Neither are necessary now that the backends are builtin. Remove both the struct size check and the MODVERSION string (which wasn't actually checked anymore). Make the init function return the given Ebl handle or NULL on error (no init function currently indicates any error). Signed-off-by: Mark Wielaard --- ChangeLog | 4 backends/ChangeLog | 20 backends/aarch64_init.c | 11 +++ backends/alpha_init.c | 11 +++ backends/arm_init.c | 11 +++ backends/bpf_init.c | 10 +++--- backends/csky_init.c| 11 +++ backends/i386_init.c| 11 +++ backends/ia64_init.c| 11 +++ backends/libebl_CPU.h | 3 +-- backends/m68k_init.c| 11 +++ backends/ppc64_init.c | 11 +++ backends/ppc_init.c | 11 +++ backends/riscv_init.c | 11 +++ backends/s390_init.c| 11 +++ backends/sh_init.c | 11 +++ backends/sparc_init.c | 11 +++ backends/tilegx_init.c | 11 +++ backends/x86_64_init.c | 11 +++ configure.ac| 6 -- libebl/ChangeLog| 9 + libebl/eblopenbackend.c | 34 +- libebl/libeblP.h| 6 -- 23 files changed, 103 insertions(+), 154 deletions(-) diff --git a/ChangeLog b/ChangeLog index 854568e0..c08af9d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-06-10 Mark Wielaard + + * configure.ac (MODVERSION): Remove. + 2020-03-30 Mark Wielaard * configure.ac: Set version to 0.179. diff --git a/backends/ChangeLog b/backends/ChangeLog index 3f5f9bb0..7d3578b0 100644 --- a/backends/ChangeLog +++ b/backends/ChangeLog @@ -1,3 +1,23 @@ +2020-06-10 Mark Wielard + + * aarch64_init.c (aarch64_init): Remove ehlen, return eh. + * alpha_init.c (alpha_init): Likewise. + * arm_init.c (arm_init): Likewise. + * bpf_init.c (bpf_init): Likewise. + * csky_init.c (csky_init): Likewise. + * i386_init.c (i386_init): Likewise. + * ia64_init.c (ia64_init): Likewise. + * m68k_init.c (m68k_init): Likewise. + * ppc64_init.c (ppc64_init): Likewise. + * ppc_init.c (ppc_init): Likewise. + * riscv_init.c (riscv_init): Likewise. + * s390_init.c (s390_init): Likewise. + * sh_init.c (sh_init): Likewise. + * sparc_init.c (sparc_init): Likewise. + * tilegx_init.c (tilegx_init): Likewise. + * x86_64_init.c (x86_64_init): Likewise. + * libebl_CPU.h (init): Adjust EBLHOOK signature. + 2019-07-05 Omar Sandoval * Makefile.am: Replace libcpu_{i386,x86_64,bpf}.a with libcpu.a. diff --git a/backends/aarch64_init.c b/backends/aarch64_init.c index 95268ae0..66bfae94 100644 --- a/backends/aarch64_init.c +++ b/backends/aarch64_init.c @@ -38,16 +38,11 @@ #include "common-reloc.c" -const char * +Ebl * aarch64_init (Elf *elf __attribute__ ((unused)), GElf_Half machine __attribute__ ((unused)), - Ebl *eh, - size_t ehlen) + Ebl *eh) { - /* Check whether the Elf_BH object has a sufficent size. */ - if (ehlen < sizeof (Ebl)) -return NULL; - /* We handle it. */ aarch64_init_reloc (eh); HOOK (eh, register_info); @@ -65,5 +60,5 @@ aarch64_init (Elf *elf __attribute__ ((unused)), HOOK (eh, set_initial_registers_tid); HOOK (eh, unwind); - return MODVERSION; + return eh; } diff --git a/backends/alpha_init.c b/backends/alpha_init.c index f66f40c5..c69aec6d 100644 --- a/backends/alpha_init.c +++ b/backends/alpha_init.c @@ -39,16 +39,11 @@ #include "common-reloc.c" -const char * +Ebl * alpha_init (Elf *elf __attribute__ ((unused)), GElf_Half machine __attribute__ ((unused)), - Ebl *eh, - size_t ehlen) + Ebl *eh) { - /* Check whether the Elf_BH object has a sufficent size. */ - if (ehlen < sizeof (Ebl)) -return NULL; - /* We handle it. */ alpha_init_reloc (eh); HOOK (eh, dynamic_tag_name); @@ -64,5 +59,5 @@ alpha_init (Elf *elf __attribute__ ((unused)), HOOK (eh, auxv_info); eh->sysvhash_entrysize = sizeof (Elf64_Xword); - return MODVERSION; + return eh; } diff --git a/backends/arm_init.c b/backends/arm_init.c index af023f02..edd53b75 100644 --- a/backends/arm_init.c +++ b/backends/arm_init.c @@ -39,16 +39,11 @@ #include "common-reloc.c" -const char * +Ebl * arm_init (Elf *elf __attribute__ ((unused)), GElf_Half machine __attribute__ ((unused)), - Ebl *eh, - size_t ehlen) + Ebl *eh) { - /* Check whether the Elf_BH ob