feat(nm): 64 bits passes /usr/lib/
This commit is contained in:
parent
f0936e0d52
commit
3ee3777174
38
src/nm.c
38
src/nm.c
|
@ -6,9 +6,9 @@ void print_symbol(Elf64_Sym sym);
|
||||||
|
|
||||||
char *get_sym_char(Elf64_Sym sym, Elf64_Shdr sec) {
|
char *get_sym_char(Elf64_Sym sym, Elf64_Shdr sec) {
|
||||||
// ppp(sym, sec);
|
// ppp(sym, sec);
|
||||||
if ((sec.sh_flags & SHF_COMPRESSED) == SHF_COMPRESSED) {
|
// if ((sec.sh_flags & SHF_COMPRESSED) == SHF_COMPRESSED) {
|
||||||
return ("N");
|
// return ("N");
|
||||||
}
|
// }
|
||||||
if (sym.st_shndx == SHN_ABS) {
|
if (sym.st_shndx == SHN_ABS) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
||||||
return ("a");
|
return ("a");
|
||||||
|
@ -17,6 +17,9 @@ char *get_sym_char(Elf64_Sym sym, Elf64_Shdr sec) {
|
||||||
return ("A");
|
return ("A");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ELF64_ST_BIND(sym.st_info) == STB_GNU_UNIQUE) {
|
||||||
|
return ("u");
|
||||||
|
}
|
||||||
if (ELF64_ST_TYPE(sym.st_info) == STT_GNU_IFUNC) {
|
if (ELF64_ST_TYPE(sym.st_info) == STT_GNU_IFUNC) {
|
||||||
return ("i");
|
return ("i");
|
||||||
}
|
}
|
||||||
|
@ -101,6 +104,7 @@ char *get_sym_char(Elf64_Sym sym, Elf64_Shdr sec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sym.st_shndx == SHN_UNDEF) {
|
if (sym.st_shndx == SHN_UNDEF) {
|
||||||
|
//return ("U");
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
||||||
return ("u");
|
return ("u");
|
||||||
}
|
}
|
||||||
|
@ -130,8 +134,6 @@ char *get_sym_char(Elf64_Sym sym, Elf64_Shdr sec) {
|
||||||
return ("w");
|
return ("w");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print_symbol(sym);
|
|
||||||
print_section(sec);
|
|
||||||
return ("W");
|
return ("W");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,29 +200,29 @@ int nm64(t_mapped_file mapped_file) {
|
||||||
ft_memcpy(&sec, mapped_file.ptr + header.e_shoff + header.e_shentsize * sym.st_shndx, header.e_shentsize);
|
ft_memcpy(&sec, mapped_file.ptr + header.e_shoff + header.e_shentsize * sym.st_shndx, header.e_shentsize);
|
||||||
}
|
}
|
||||||
char *str;
|
char *str;
|
||||||
|
char *sec_str;
|
||||||
|
Elf64_Shdr shdr;
|
||||||
|
if (sym.st_shndx != SHN_ABS) {
|
||||||
|
ft_memcpy(&shdr, mapped_file.ptr + header.e_shoff + header.e_shentsize * sym.st_shndx, header.e_shentsize);
|
||||||
|
sec_str = ft_strdup(mapped_file.ptr + shstrtb.sh_offset + shdr.sh_name);
|
||||||
|
} else {
|
||||||
|
sec_str = ft_strdup("");
|
||||||
|
}
|
||||||
if (sym.st_name) {
|
if (sym.st_name) {
|
||||||
str = ft_strdup(mapped_file.ptr + strtab.sh_offset + sym.st_name);
|
str = ft_strdup(mapped_file.ptr + strtab.sh_offset + sym.st_name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//printf("good\n");
|
str = sec_str;
|
||||||
Elf64_Shdr shdr;
|
|
||||||
//print_symbol(sym);
|
|
||||||
if (sym.st_shndx != SHN_ABS) {
|
|
||||||
ft_memcpy(&shdr, mapped_file.ptr + header.e_shoff + header.e_shentsize * sym.st_shndx, header.e_shentsize);
|
|
||||||
//print_section(shdr);
|
|
||||||
//ft_printf("sxs", "sh string table ", shstrtb.sh_offset, "\n");
|
|
||||||
str = ft_strdup(mapped_file.ptr + shstrtb.sh_offset + shdr.sh_name);
|
|
||||||
//str = ft_strdup("TOTOTOTOTO");
|
|
||||||
//str = ft_strdup(mapped_file.ptr + shdr.sh_offset + sec.sh_name);
|
|
||||||
} else {
|
|
||||||
str = ft_strdup("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//if (str[ft_strlen(str) - 1] == 'c') {
|
//if (str[ft_strlen(str) - 1] == 'c') {
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
//}
|
//}
|
||||||
char *sym_char = ft_strdup(get_sym_char(sym, sec));
|
char *sym_char = ft_strdup(get_sym_char(sym, sec));
|
||||||
|
if (ft_strnstr(sec_str, ".debug", 6) && ft_strequ(sym_char, "n")) {
|
||||||
|
free(sym_char);
|
||||||
|
sym_char = ft_strdup("N");
|
||||||
|
}
|
||||||
if (sym.st_value) {
|
if (sym.st_value) {
|
||||||
ft_printf("X s ss", sym.st_value, sym_char, str, "\n");
|
ft_printf("X s ss", sym.st_value, sym_char, str, "\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue