https://sourceware.org/bugzilla/show_bug.cgi?id=31447
--- Comment #4 from Di Chen <dichen at redhat dot com> --- @mjw I have function dwelf_relocation_debug_sections() added in libdwelf.a. ``` $ pwd /home/dichen/elfutils $ eu-readelf -s libdwelf/libdwelf.a | grep dwelf_relocation_debug_sections libdwelf/libdwelf.a(dwelf_relocation_debug_sections.o): 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS dwelf_relocation_debug_sections.c 290: 000000000000077c 3783 FUNC GLOBAL DEFAULT 126 dwelf_relocation_debug_sections ``` And I can call the new function in a test program: ``` #include <fcntl.h> #include <gelf.h> #include <libelf.h> #include <stdio.h> #include <unistd.h> #include "libdwelf.h" int main(int argc, char **argv) { const char *fname = argv[1]; elf_version(EV_CURRENT); int fd = open(argv[1], O_RDWR); Elf *elf; elf = elf_begin(fd, ELF_C_RDWR, NULL); dwelf_relocation_debug_sections(elf, fname); elf_update(elf, ELF_C_WRITE); return 0; } // $ gcc reloc.c -l elf -l dwelf -l dw -l ebl -l ebl_backends -l cpu -L ../libcpu -L ../libebl -L ../backends -L ../libdwelf -I ../libdwelf -I ../libdw -g -o reloc ``` Then, I am thinking of making strip.c use this dwelf_relocation_debug_sections() so that I can reduce some code redundancy. ``` diff --git a/src/Makefile.am b/src/Makefile.am index 1d592d4d..746c8817 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,6 +43,8 @@ if BUILD_STATIC libasm = ../libasm/libasm.a libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) -ldl -lpthread libelf = ../libelf/libelf.a -lz $(zstd_LIBS) +libebl = ../libebl/libebl.a ../backends/libebl_backends.a ../libcpu/libcpu.a +libdwelf = ../libdwelf/libdwelf.a if LIBDEBUGINFOD libdebuginfod = ../debuginfod/libdebuginfod.a -lpthread $(libcurl_LIBS) else @@ -60,6 +62,7 @@ endif endif libebl = ../libebl/libebl.a ../backends/libebl_backends.a ../libcpu/libcpu.a libeu = ../lib/libeu.a +libdwelf = ../libdwelf/libdwelf.a if DEMANGLE demanglelib = -lstdc++ @@ -81,7 +84,7 @@ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) \ $(demanglelib) size_LDADD = $(libelf) $(libeu) $(argp_LDADD) -strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) +strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(libdwelf) $(argp_LDADD) elflint_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD) findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib) ``` After the above Makefile.am change, still, elfutils building kept failing due to some undefined reference error. ``` /usr/bin/ld: strip.o: in function `handle_debug_relocs': /home/dichen/elfutils/src/strip.c:576: undefined reference to `dwelf_relocation_debug_sections' /usr/bin/ld: strip.o: in function `handle_elf': /home/dichen/elfutils/src/strip.c:2123: undefined reference to `dwelf_relocation_debug_sections' collect2: error: ld returned 1 exit status ``` I believe I am missing something in the building process(Makefile.am, Makefile.in, etc). But I don't have many clue now, could you please give a look? CC: @amerey -- You are receiving this mail because: You are on the CC list for the bug.