From 5d3ec27b766a18a12869de6c7fa357083c27cd5c Mon Sep 17 00:00:00 2001 From: zy Date: Thu, 7 Dec 2023 21:49:11 -0500 Subject: [PATCH] rm Dwarf --- source/ucli/Makefile | 3 +- source/ucli/elf.cc | 80 ++++++++++++++++++++++---------------------- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/source/ucli/Makefile b/source/ucli/Makefile index 7b5fd9a..dd0bf10 100644 --- a/source/ucli/Makefile +++ b/source/ucli/Makefile @@ -5,7 +5,8 @@ OBJECTS=$(SOURCES:.cc=.o) CFLAGS=-g -O0 INCLUDES=-I/usr/include/elf -LIBS=-lunwind-x86_64 -lunwind -lelf -ldwarf -ldw +LIBS=-lunwind-x86_64 -lunwind -lelf +#-ldwarf -ldw %.o: %.cc $(CXX) $(CFLAGS) $(INCLUDES) -c $< -o $@ diff --git a/source/ucli/elf.cc b/source/ucli/elf.cc index b0c1d70..25db08b 100644 --- a/source/ucli/elf.cc +++ b/source/ucli/elf.cc @@ -8,8 +8,8 @@ #include #include -#include -#include +// #include +// #include #define NS_NAME_LEN 128 @@ -227,44 +227,44 @@ static void get_all_symbols(std::set &ss, symbol_sections_ctx *si, __get_plt_symbol(ss, si, elf); } -static void get_debug_symbols(std::set& ss, Dwarf* dw) { - Dwarf_Off die_offset = 0, next_offset; - size_t header_size; - while (dwarf_nextcu(dw, die_offset, &next_offset, &header_size, NULL, NULL, NULL) == 0) { - Dwarf_Die cudie; - if (dwarf_offdie(dw, die_offset + header_size, &cudie) == NULL) { - continue; - } +// static void get_debug_symbols(std::set& ss, Dwarf* dw) { +// Dwarf_Off die_offset = 0, next_offset; +// size_t header_size; +// while (dwarf_nextcu(dw, die_offset, &next_offset, &header_size, NULL, NULL, NULL) == 0) { +// Dwarf_Die cudie; +// if (dwarf_offdie(dw, die_offset + header_size, &cudie) == NULL) { +// continue; +// } - Dwarf_Die die; - if (dwarf_child(&cudie, &die) != 0) { - continue; - } +// Dwarf_Die die; +// if (dwarf_child(&cudie, &die) != 0) { +// continue; +// } - do { - const char* die_name = dwarf_diename(&die); - if (!die_name) { - continue; - } +// do { +// const char* die_name = dwarf_diename(&die); +// if (!die_name) { +// continue; +// } - Dwarf_Attribute attr_mem; - Dwarf_Attribute* attr = dwarf_attr(&die, DW_AT_low_pc, &attr_mem); - if (attr) { - Dwarf_Addr low_pc; - if (dwarf_formaddr(attr, &low_pc) == 0) { - symbol s; - s.name = die_name; - s.start = low_pc; - s.end = s.start; // You need to find the high_pc to set the end. +// Dwarf_Attribute attr_mem; +// Dwarf_Attribute* attr = dwarf_attr(&die, DW_AT_low_pc, &attr_mem); +// if (attr) { +// Dwarf_Addr low_pc; +// if (dwarf_formaddr(attr, &low_pc) == 0) { +// symbol s; +// s.name = die_name; +// s.start = low_pc; +// s.end = s.start; // You need to find the high_pc to set the end. - ss.insert(s); - } - } - } while (dwarf_siblingof(&die, &die) == 0); +// ss.insert(s); +// } +// } +// } while (dwarf_siblingof(&die, &die) == 0); - die_offset = next_offset; - } -} +// die_offset = next_offset; +// } +// } bool get_symbol_from_elf(std::set &ss, const char *path) { static int first_init = 0; @@ -375,11 +375,11 @@ bool get_symbol_from_elf(std::set &ss, const char *path) { elf_end(elf); // After getting all symbols from .symtab and .dynsym - Dwarf *dw = dwarf_begin(fd, DWARF_C_READ); - if (dw) { - get_debug_symbols(ss, dw); - dwarf_end(dw); - } + // Dwarf *dw = dwarf_begin(fd, DWARF_C_READ); + // if (dw) { + // get_debug_symbols(ss, dw); + // dwarf_end(dw); + // } close(fd); return true;