Compare commits
2 Commits
6c42540095
...
71c9d7703f
Author | SHA1 | Date |
---|---|---|
gbrochar | 71c9d7703f | |
gbrochar | 88ed6d1ad9 |
|
@ -98,6 +98,7 @@ int nm(char *path, t_verbosity verbosity, t_ordering ordering) {
|
||||||
if (!ident_ptr) {
|
if (!ident_ptr) {
|
||||||
ft_printf("sss", "nm: ", path, ": file format not recognized\n");
|
ft_printf("sss", "nm: ", path, ": file format not recognized\n");
|
||||||
munmap(mapped_file.ptr, mapped_file.size);
|
munmap(mapped_file.ptr, mapped_file.size);
|
||||||
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -105,12 +106,14 @@ int nm(char *path, t_verbosity verbosity, t_ordering ordering) {
|
||||||
if (check_ident(ident) == FT_NM_FAILURE) {
|
if (check_ident(ident) == FT_NM_FAILURE) {
|
||||||
ft_printf("sss", "nm: ", path, ": file format not recognized\n");
|
ft_printf("sss", "nm: ", path, ": file format not recognized\n");
|
||||||
munmap(mapped_file.ptr, mapped_file.size);
|
munmap(mapped_file.ptr, mapped_file.size);
|
||||||
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (ident[EI_CLASS] == ELFCLASS32) {
|
if (ident[EI_CLASS] == ELFCLASS32) {
|
||||||
if (nm32(mapped_file, path, verbosity, ordering) == FT_NM_FAILURE) {
|
if (nm32(mapped_file, path, verbosity, ordering) == FT_NM_FAILURE) {
|
||||||
ft_printf("sss", "nm: ", path, ": file format not recognized\n");
|
ft_printf("sss", "nm: ", path, ": file format not recognized\n");
|
||||||
munmap(mapped_file.ptr, mapped_file.size);
|
munmap(mapped_file.ptr, mapped_file.size);
|
||||||
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,6 +121,7 @@ int nm(char *path, t_verbosity verbosity, t_ordering ordering) {
|
||||||
if (nm64(mapped_file, path, verbosity, ordering) == FT_NM_FAILURE) {
|
if (nm64(mapped_file, path, verbosity, ordering) == FT_NM_FAILURE) {
|
||||||
ft_printf("sss", "nm: ", path, ": file format not recognized\n");
|
ft_printf("sss", "nm: ", path, ": file format not recognized\n");
|
||||||
munmap(mapped_file.ptr, mapped_file.size);
|
munmap(mapped_file.ptr, mapped_file.size);
|
||||||
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,8 +162,8 @@ int main(int ac, char **av) {
|
||||||
}
|
}
|
||||||
t_list *tmp = env.list;
|
t_list *tmp = env.list;
|
||||||
while (tmp) {
|
while (tmp) {
|
||||||
ft_printf("\ns:\n", env.list->content);
|
ft_printf("\ns:\n", tmp->content);
|
||||||
nm(env.list->content, env.verbosity, env.ordering);
|
nm(tmp->content, env.verbosity, env.ordering);
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
free_env(env);
|
free_env(env);
|
||||||
|
|
178
src/nm.c
178
src/nm.c
|
@ -1,122 +1,122 @@
|
||||||
#include "ft_nm.h"
|
#include "ft_nm.h"
|
||||||
|
|
||||||
char *get_sym_char(Elf64_Sym sym, Elf64_Shdr sec, int *tool) {
|
char *get_sym_char(Elf64_Sym *sym, Elf64_Shdr *sec, int *tool) {
|
||||||
*tool = 0;
|
*tool = 0;
|
||||||
if (ELF64_ST_TYPE(sym.st_info) == STT_SECTION) {
|
if (ELF64_ST_TYPE(sym->st_info) == STT_SECTION) {
|
||||||
*tool = 1;
|
*tool = 1;
|
||||||
}
|
}
|
||||||
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");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("A");
|
return ("A");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_GNU_UNIQUE) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_GNU_UNIQUE) {
|
||||||
return ("u");
|
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");
|
||||||
}
|
}
|
||||||
if (sec.sh_flags & SHF_EXECINSTR) {
|
if (sec->sh_flags & SHF_EXECINSTR) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("t");
|
return ("t");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("T");
|
return ("T");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_NOBITS) {
|
if (sec->sh_type == SHT_NOBITS) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("b");
|
return ("b");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("B");
|
return ("B");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_PROGBITS && (sec.sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
if (sec->sh_type == SHT_PROGBITS && (sec->sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("d");
|
return ("d");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("D");
|
return ("D");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_DYNAMIC && (sec.sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
if (sec->sh_type == SHT_DYNAMIC && (sec->sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("d");
|
return ("d");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("D");
|
return ("D");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_INIT_ARRAY && (sec.sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
if (sec->sh_type == SHT_INIT_ARRAY && (sec->sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("d");
|
return ("d");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("D");
|
return ("D");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_PREINIT_ARRAY && (sec.sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
if (sec->sh_type == SHT_PREINIT_ARRAY && (sec->sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("d");
|
return ("d");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("D");
|
return ("D");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_FINI_ARRAY && (sec.sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
if (sec->sh_type == SHT_FINI_ARRAY && (sec->sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("d");
|
return ("d");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("D");
|
return ("D");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_flags & SHF_ALLOC) {
|
if (sec->sh_flags & SHF_ALLOC) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("r");
|
return ("r");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("R");
|
return ("R");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_NOTE && sec.sh_flags == SHF_ALLOC) {
|
if (sec->sh_type == SHT_NOTE && sec->sh_flags == SHF_ALLOC) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("r");
|
return ("r");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("R");
|
return ("R");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sym.st_shndx == SHN_COMMON) {
|
if (sym->st_shndx == SHN_COMMON) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("c");
|
return ("c");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("C");
|
return ("C");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sym.st_shndx == SHN_UNDEF) {
|
if (sym->st_shndx == SHN_UNDEF) {
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("u");
|
return ("u");
|
||||||
}
|
}
|
||||||
else if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("U");
|
return ("U");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_WEAK) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_WEAK) {
|
||||||
if (ELF64_ST_TYPE(sym.st_info) == STT_OBJECT) {
|
if (ELF64_ST_TYPE(sym->st_info) == STT_OBJECT) {
|
||||||
if (sec.sh_type == SHT_NULL) {
|
if (sec->sh_type == SHT_NULL) {
|
||||||
return ("v");
|
return ("v");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ("V");
|
return ("V");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sec.sh_type == SHT_NULL) {
|
if (sec->sh_type == SHT_NULL) {
|
||||||
return ("w");
|
return ("w");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -124,8 +124,8 @@ char *get_sym_char(Elf64_Sym sym, Elf64_Shdr sec, int *tool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ELF64_ST_BIND(sym.st_info) == STB_WEAK) {
|
if (ELF64_ST_BIND(sym->st_info) == STB_WEAK) {
|
||||||
if (sec.sh_type == SHT_NULL) {
|
if (sec->sh_type == SHT_NULL) {
|
||||||
return ("w");
|
return ("w");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -136,49 +136,70 @@ char *get_sym_char(Elf64_Sym sym, Elf64_Shdr sec, int *tool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int nm64(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_ordering ordering) {
|
int nm64(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_ordering ordering) {
|
||||||
t_root *tree = NULL;
|
|
||||||
t_entry *entry = (t_entry *)malloc(sizeof(t_entry));
|
|
||||||
int tool;
|
|
||||||
if (!entry)
|
|
||||||
return FT_NM_FAILURE;
|
|
||||||
Elf64_Ehdr header;
|
Elf64_Ehdr header;
|
||||||
if (get_header64(mapped_file, &header) == FT_NM_FAILURE) {
|
if (get_header64(mapped_file, &header) == FT_NM_FAILURE) {
|
||||||
return FT_NM_FAILURE;
|
return FT_NM_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (header.e_ehsize != 64) {
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
}
|
||||||
uint64_t addr = header.e_shoff + header.e_shentsize * header.e_shstrndx;
|
uint64_t addr = header.e_shoff + header.e_shentsize * header.e_shstrndx;
|
||||||
Elf64_Shdr shstrtb;
|
Elf64_Shdr *shstrtb;
|
||||||
shstrtb = *(Elf64_Shdr *)fetch(mapped_file, addr, header.e_shentsize);
|
if (!(shstrtb = (Elf64_Shdr *)fetch(mapped_file, addr, header.e_shentsize))) {
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
}
|
||||||
|
t_root *tree = NULL;
|
||||||
|
t_entry *entry = (t_entry *)malloc(sizeof(t_entry));
|
||||||
|
if (!entry)
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
int tool;
|
||||||
for (int i = 0; i < header.e_shnum; i++) {
|
for (int i = 0; i < header.e_shnum; i++) {
|
||||||
uint64_t addr = header.e_shoff + header.e_shentsize * i;
|
uint64_t addr = header.e_shoff + header.e_shentsize * i;
|
||||||
Elf64_Shdr sh;
|
Elf64_Shdr *sh;
|
||||||
sh = *(Elf64_Shdr *)fetch(mapped_file, addr, header.e_shentsize);
|
if (!(sh = (Elf64_Shdr *)fetch(mapped_file, addr, header.e_shentsize))) {
|
||||||
if (sh.sh_type == SHT_SYMTAB) {
|
free(entry);
|
||||||
uint64_t addr2 = header.e_shoff + header.e_shentsize * sh.sh_link;
|
return FT_NM_FAILURE;
|
||||||
Elf64_Shdr strtab;
|
}
|
||||||
strtab = *(Elf64_Shdr *)fetch(mapped_file, addr2, header.e_shentsize);
|
if (sh->sh_type == SHT_SYMTAB) {
|
||||||
char first = *(char *)fetch(mapped_file, strtab.sh_offset, 1);
|
uint64_t addr2 = header.e_shoff + header.e_shentsize * sh->sh_link;
|
||||||
char last = *(char *)fetch(mapped_file, strtab.sh_offset + strtab.sh_size - 1, 1);
|
Elf64_Shdr *strtab;
|
||||||
if (first != '\0' || last != '\0') {
|
if (!(strtab = (Elf64_Shdr *)fetch(mapped_file, addr2, header.e_shentsize))) {
|
||||||
|
free(entry);
|
||||||
return FT_NM_FAILURE;
|
return FT_NM_FAILURE;
|
||||||
}
|
}
|
||||||
for (uint64_t j = sh.sh_entsize; j < sh.sh_size; j += sh.sh_entsize) {
|
char *first = (char *)fetch(mapped_file, strtab->sh_offset, 1);
|
||||||
Elf64_Sym sym;
|
char *last = (char *)fetch(mapped_file, strtab->sh_offset + strtab->sh_size - 1, 1);
|
||||||
Elf64_Shdr sec;
|
if (!first || !last || *first != '\0' || *last != '\0') {
|
||||||
sym = *(Elf64_Sym *)fetch(mapped_file, sh.sh_offset + j, sh.sh_entsize);
|
free(entry);
|
||||||
if (sym.st_shndx < header.e_shnum) {
|
return FT_NM_FAILURE;
|
||||||
sec = *(Elf64_Shdr *)fetch(mapped_file, header.e_shoff + header.e_shentsize * sym.st_shndx, header.e_shentsize);
|
}
|
||||||
|
for (uint64_t j = sh->sh_entsize; j < sh->sh_size; j += sh->sh_entsize) {
|
||||||
|
Elf64_Sym *sym;
|
||||||
|
Elf64_Shdr *sec;
|
||||||
|
if (!(sym = (Elf64_Sym *)fetch(mapped_file, sh->sh_offset + j, sh->sh_entsize))) {
|
||||||
|
free(entry);
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
}
|
||||||
|
if (sym->st_shndx < header.e_shnum) {
|
||||||
|
if (!(sec = (Elf64_Shdr *)fetch(mapped_file, header.e_shoff + header.e_shentsize * sym->st_shndx, header.e_shentsize))) {
|
||||||
|
free(entry);
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
char *str;
|
char *str;
|
||||||
char *sec_str;
|
char *sec_str;
|
||||||
Elf64_Shdr shdr;
|
Elf64_Shdr *shdr;
|
||||||
if (sym.st_shndx != SHN_ABS) {
|
if (sym->st_shndx != SHN_ABS) {
|
||||||
shdr = *(Elf64_Shdr *)fetch(mapped_file, header.e_shoff + header.e_shentsize * sym.st_shndx, header.e_shentsize);
|
if (!(shdr = (Elf64_Shdr *)fetch(mapped_file, 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);
|
free(entry);
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
}
|
||||||
|
sec_str = ft_strdup(mapped_file.ptr + shstrtb->sh_offset + shdr->sh_name);
|
||||||
} else {
|
} else {
|
||||||
sec_str = ft_strdup("");
|
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 {
|
||||||
str = sec_str;
|
str = sec_str;
|
||||||
|
@ -197,7 +218,7 @@ int nm64(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_orderin
|
||||||
// ici le sym char a ete calculer, a partir de la on determine la verbosity
|
// ici le sym char a ete calculer, a partir de la on determine la verbosity
|
||||||
// ici on fait if entry->verbosity >= verbosity, si c'est pas bon on skip toute la suite
|
// ici on fait if entry->verbosity >= verbosity, si c'est pas bon on skip toute la suite
|
||||||
entry->verbosity = DEFAULT_VERBOSITY;
|
entry->verbosity = DEFAULT_VERBOSITY;
|
||||||
if ((sym_char[0] == 'a' && sym.st_info == 4) || sym_char[0] == 'N' || tool == 1)
|
if ((sym_char[0] == 'a' && sym->st_info == 4) || sym_char[0] == 'N' || tool == 1)
|
||||||
entry->verbosity = ALL;
|
entry->verbosity = ALL;
|
||||||
if (sym_char[0] == 'u' || sym_char[0] == 'v' || sym_char[0] == 'w' || (sym_char[0] >= 'A' && sym_char[0] <= 'Z' && sym_char[0] != 'N'))
|
if (sym_char[0] == 'u' || sym_char[0] == 'v' || sym_char[0] == 'w' || (sym_char[0] >= 'A' && sym_char[0] <= 'Z' && sym_char[0] != 'N'))
|
||||||
entry->verbosity = GLOBAL;
|
entry->verbosity = GLOBAL;
|
||||||
|
@ -216,15 +237,15 @@ int nm64(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_orderin
|
||||||
entry->string[17] = sym_char[0];
|
entry->string[17] = sym_char[0];
|
||||||
entry->string[18] = ' ';
|
entry->string[18] = ' ';
|
||||||
ft_memcpy(entry->string + 19, entry->symbol, ft_strlen(entry->symbol));
|
ft_memcpy(entry->string + 19, entry->symbol, ft_strlen(entry->symbol));
|
||||||
if (sym.st_value && !ft_strstr(entry->symbol, "@@")) {
|
if (sym->st_value && !ft_strstr(entry->symbol, "@@")) {
|
||||||
for (char i = 15; i >= 0; i--) {
|
for (char i = 15; i >= 0; i--) {
|
||||||
entry->string[15 - i] = ft_get_hex_digit((sym.st_value >> i * 4) & 0xF);
|
entry->string[15 - i] = ft_get_hex_digit((sym->st_value >> i * 4) & 0xF);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ft_strcmp(sym_char, "U") && ft_strcmp(sym_char, "w") && ft_strcmp(sym_char, "v")) {
|
if (ft_strcmp(sym_char, "U") && ft_strcmp(sym_char, "w") && ft_strcmp(sym_char, "v")) {
|
||||||
|
|
||||||
for (char i = 15; i >= 0; i--) {
|
for (char i = 15; i >= 0; i--) {
|
||||||
entry->string[15 - i] = ft_get_hex_digit((sym.st_value >> i * 4) & 0xF);
|
entry->string[15 - i] = ft_get_hex_digit((sym->st_value >> i * 4) & 0xF);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
|
@ -244,7 +265,6 @@ int nm64(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_orderin
|
||||||
ft_rbt_insert(&tree, ft_rbt_new((void *)entry, sizeof(t_entry)), &strcmp_nm);
|
ft_rbt_insert(&tree, ft_rbt_new((void *)entry, sizeof(t_entry)), &strcmp_nm);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
|
||||||
} else {
|
} else {
|
||||||
free(entry->symbol);
|
free(entry->symbol);
|
||||||
free(sym_char);
|
free(sym_char);
|
||||||
|
|
178
src/nm32.c
178
src/nm32.c
|
@ -1,122 +1,122 @@
|
||||||
#include "ft_nm.h"
|
#include "ft_nm.h"
|
||||||
|
|
||||||
char *get_sym_char32(Elf32_Sym sym, Elf32_Shdr sec, int *tool) {
|
char *get_sym_char32(Elf32_Sym *sym, Elf32_Shdr *sec, int *tool) {
|
||||||
*tool = 0;
|
*tool = 0;
|
||||||
if (ELF32_ST_TYPE(sym.st_info) == STT_SECTION) {
|
if (ELF32_ST_TYPE(sym->st_info) == STT_SECTION) {
|
||||||
*tool = 1;
|
*tool = 1;
|
||||||
}
|
}
|
||||||
if (sym.st_shndx == SHN_ABS) {
|
if (sym->st_shndx == SHN_ABS) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("a");
|
return ("a");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("A");
|
return ("A");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_GNU_UNIQUE) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_GNU_UNIQUE) {
|
||||||
return ("u");
|
return ("u");
|
||||||
}
|
}
|
||||||
if (ELF32_ST_TYPE(sym.st_info) == STT_GNU_IFUNC) {
|
if (ELF32_ST_TYPE(sym->st_info) == STT_GNU_IFUNC) {
|
||||||
return ("i");
|
return ("i");
|
||||||
}
|
}
|
||||||
if (sec.sh_flags & SHF_EXECINSTR) {
|
if (sec->sh_flags & SHF_EXECINSTR) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("t");
|
return ("t");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("T");
|
return ("T");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_NOBITS) {
|
if (sec->sh_type == SHT_NOBITS) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("b");
|
return ("b");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("B");
|
return ("B");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_PROGBITS && (sec.sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
if (sec->sh_type == SHT_PROGBITS && (sec->sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("d");
|
return ("d");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("D");
|
return ("D");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_DYNAMIC && (sec.sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
if (sec->sh_type == SHT_DYNAMIC && (sec->sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("d");
|
return ("d");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("D");
|
return ("D");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_INIT_ARRAY && (sec.sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
if (sec->sh_type == SHT_INIT_ARRAY && (sec->sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("d");
|
return ("d");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("D");
|
return ("D");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_PREINIT_ARRAY && (sec.sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
if (sec->sh_type == SHT_PREINIT_ARRAY && (sec->sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("d");
|
return ("d");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("D");
|
return ("D");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_FINI_ARRAY && (sec.sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
if (sec->sh_type == SHT_FINI_ARRAY && (sec->sh_flags & (SHF_ALLOC | SHF_WRITE)) == (SHF_ALLOC | SHF_WRITE)) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("d");
|
return ("d");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("D");
|
return ("D");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_flags & SHF_ALLOC) {
|
if (sec->sh_flags & SHF_ALLOC) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("r");
|
return ("r");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("R");
|
return ("R");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sec.sh_type == SHT_NOTE && sec.sh_flags == SHF_ALLOC) {
|
if (sec->sh_type == SHT_NOTE && sec->sh_flags == SHF_ALLOC) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("r");
|
return ("r");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("R");
|
return ("R");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sym.st_shndx == SHN_COMMON) {
|
if (sym->st_shndx == SHN_COMMON) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("c");
|
return ("c");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("C");
|
return ("C");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sym.st_shndx == SHN_UNDEF) {
|
if (sym->st_shndx == SHN_UNDEF) {
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_LOCAL) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL) {
|
||||||
return ("u");
|
return ("u");
|
||||||
}
|
}
|
||||||
else if (ELF32_ST_BIND(sym.st_info) == STB_GLOBAL) {
|
else if (ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
|
||||||
return ("U");
|
return ("U");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_WEAK) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_WEAK) {
|
||||||
if (ELF32_ST_TYPE(sym.st_info) == STT_OBJECT) {
|
if (ELF32_ST_TYPE(sym->st_info) == STT_OBJECT) {
|
||||||
if (sec.sh_type == SHT_NULL) {
|
if (sec->sh_type == SHT_NULL) {
|
||||||
return ("v");
|
return ("v");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ("V");
|
return ("V");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sec.sh_type == SHT_NULL) {
|
if (sec->sh_type == SHT_NULL) {
|
||||||
return ("w");
|
return ("w");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -124,8 +124,8 @@ char *get_sym_char32(Elf32_Sym sym, Elf32_Shdr sec, int *tool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ELF32_ST_BIND(sym.st_info) == STB_WEAK) {
|
if (ELF32_ST_BIND(sym->st_info) == STB_WEAK) {
|
||||||
if (sec.sh_type == SHT_NULL) {
|
if (sec->sh_type == SHT_NULL) {
|
||||||
return ("w");
|
return ("w");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -136,49 +136,70 @@ char *get_sym_char32(Elf32_Sym sym, Elf32_Shdr sec, int *tool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int nm32(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_ordering ordering) {
|
int nm32(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_ordering ordering) {
|
||||||
t_root *tree = NULL;
|
|
||||||
t_entry *entry = (t_entry *)malloc(sizeof(t_entry));
|
|
||||||
int tool;
|
|
||||||
if (!entry)
|
|
||||||
return FT_NM_FAILURE;
|
|
||||||
Elf32_Ehdr header;
|
Elf32_Ehdr header;
|
||||||
if (get_header32(mapped_file, &header) == FT_NM_FAILURE) {
|
if (get_header32(mapped_file, &header) == FT_NM_FAILURE) {
|
||||||
return FT_NM_FAILURE;
|
return FT_NM_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (header.e_ehsize != 52) {
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
}
|
||||||
uint32_t addr = header.e_shoff + header.e_shentsize * header.e_shstrndx;
|
uint32_t addr = header.e_shoff + header.e_shentsize * header.e_shstrndx;
|
||||||
Elf32_Shdr shstrtb;
|
Elf32_Shdr *shstrtb;
|
||||||
shstrtb = *(Elf32_Shdr *)fetch(mapped_file, addr, header.e_shentsize);
|
if (!(shstrtb = (Elf32_Shdr *)fetch(mapped_file, addr, header.e_shentsize))) {
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
}
|
||||||
|
t_root *tree = NULL;
|
||||||
|
t_entry *entry = (t_entry *)malloc(sizeof(t_entry));
|
||||||
|
if (!entry)
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
int tool;
|
||||||
for (int i = 0; i < header.e_shnum; i++) {
|
for (int i = 0; i < header.e_shnum; i++) {
|
||||||
uint32_t addr = header.e_shoff + header.e_shentsize * i;
|
uint32_t addr = header.e_shoff + header.e_shentsize * i;
|
||||||
Elf32_Shdr sh;
|
Elf32_Shdr *sh;
|
||||||
sh = *(Elf32_Shdr *)fetch(mapped_file, addr, header.e_shentsize);
|
if (!(sh = (Elf32_Shdr *)fetch(mapped_file, addr, header.e_shentsize))) {
|
||||||
if (sh.sh_type == SHT_SYMTAB) {
|
free(entry);
|
||||||
uint32_t addr2 = header.e_shoff + header.e_shentsize * sh.sh_link;
|
return FT_NM_FAILURE;
|
||||||
Elf32_Shdr strtab;
|
}
|
||||||
strtab = *(Elf32_Shdr *)fetch(mapped_file, addr2, header.e_shentsize);
|
if (sh->sh_type == SHT_SYMTAB) {
|
||||||
char first = *(char *)fetch(mapped_file, strtab.sh_offset, 1);
|
uint32_t addr2 = header.e_shoff + header.e_shentsize * sh->sh_link;
|
||||||
char last = *(char *)fetch(mapped_file, strtab.sh_offset + strtab.sh_size - 1, 1);
|
Elf32_Shdr *strtab;
|
||||||
if (first != '\0' || last != '\0') {
|
if (!(strtab = (Elf32_Shdr *)fetch(mapped_file, addr2, header.e_shentsize))) {
|
||||||
|
free(entry);
|
||||||
return FT_NM_FAILURE;
|
return FT_NM_FAILURE;
|
||||||
}
|
}
|
||||||
for (uint64_t j = sh.sh_entsize; j < sh.sh_size; j += sh.sh_entsize) {
|
char *first = (char *)fetch(mapped_file, strtab->sh_offset, 1);
|
||||||
Elf32_Sym sym;
|
char *last = (char *)fetch(mapped_file, strtab->sh_offset + strtab->sh_size - 1, 1);
|
||||||
Elf32_Shdr sec;
|
if (!first || !last || *first != '\0' || *last != '\0') {
|
||||||
sym = *(Elf32_Sym *)fetch(mapped_file, sh.sh_offset + j, sh.sh_entsize);
|
free(entry);
|
||||||
if (sym.st_shndx < header.e_shnum) {
|
return FT_NM_FAILURE;
|
||||||
sec = *(Elf32_Shdr *)fetch(mapped_file, header.e_shoff + header.e_shentsize * sym.st_shndx, header.e_shentsize);
|
}
|
||||||
|
for (uint32_t j = sh->sh_entsize; j < sh->sh_size; j += sh->sh_entsize) {
|
||||||
|
Elf32_Sym *sym;
|
||||||
|
Elf32_Shdr *sec;
|
||||||
|
if (!(sym = (Elf32_Sym *)fetch(mapped_file, sh->sh_offset + j, sh->sh_entsize))) {
|
||||||
|
free(entry);
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
}
|
||||||
|
if (sym->st_shndx < header.e_shnum) {
|
||||||
|
if (!(sec = (Elf32_Shdr *)fetch(mapped_file, header.e_shoff + header.e_shentsize * sym->st_shndx, header.e_shentsize))) {
|
||||||
|
free(entry);
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
char *str;
|
char *str;
|
||||||
char *sec_str;
|
char *sec_str;
|
||||||
Elf32_Shdr shdr;
|
Elf32_Shdr *shdr;
|
||||||
if (sym.st_shndx != SHN_ABS) {
|
if (sym->st_shndx != SHN_ABS) {
|
||||||
shdr = *(Elf32_Shdr *)fetch(mapped_file, header.e_shoff + header.e_shentsize * sym.st_shndx, header.e_shentsize);
|
if (!(shdr = (Elf32_Shdr *)fetch(mapped_file, 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);
|
free(entry);
|
||||||
|
return FT_NM_FAILURE;
|
||||||
|
}
|
||||||
|
sec_str = ft_strdup(mapped_file.ptr + shstrtb->sh_offset + shdr->sh_name);
|
||||||
} else {
|
} else {
|
||||||
sec_str = ft_strdup("");
|
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 {
|
||||||
str = sec_str;
|
str = sec_str;
|
||||||
|
@ -197,7 +218,7 @@ int nm32(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_orderin
|
||||||
// ici le sym char a ete calculer, a partir de la on determine la verbosity
|
// ici le sym char a ete calculer, a partir de la on determine la verbosity
|
||||||
// ici on fait if entry->verbosity >= verbosity, si c'est pas bon on skip toute la suite
|
// ici on fait if entry->verbosity >= verbosity, si c'est pas bon on skip toute la suite
|
||||||
entry->verbosity = DEFAULT_VERBOSITY;
|
entry->verbosity = DEFAULT_VERBOSITY;
|
||||||
if ((sym_char[0] == 'a' && sym.st_info == 4) || sym_char[0] == 'N' || tool == 1)
|
if ((sym_char[0] == 'a' && sym->st_info == 4) || sym_char[0] == 'N' || tool == 1)
|
||||||
entry->verbosity = ALL;
|
entry->verbosity = ALL;
|
||||||
if (sym_char[0] == 'u' || sym_char[0] == 'v' || sym_char[0] == 'w' || (sym_char[0] >= 'A' && sym_char[0] <= 'Z' && sym_char[0] != 'N'))
|
if (sym_char[0] == 'u' || sym_char[0] == 'v' || sym_char[0] == 'w' || (sym_char[0] >= 'A' && sym_char[0] <= 'Z' && sym_char[0] != 'N'))
|
||||||
entry->verbosity = GLOBAL;
|
entry->verbosity = GLOBAL;
|
||||||
|
@ -216,15 +237,15 @@ int nm32(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_orderin
|
||||||
entry->string[9] = sym_char[0];
|
entry->string[9] = sym_char[0];
|
||||||
entry->string[10] = ' ';
|
entry->string[10] = ' ';
|
||||||
ft_memcpy(entry->string + 11, entry->symbol, ft_strlen(entry->symbol));
|
ft_memcpy(entry->string + 11, entry->symbol, ft_strlen(entry->symbol));
|
||||||
if (sym.st_value && !ft_strstr(entry->symbol, "@@")) {
|
if (sym->st_value && !ft_strstr(entry->symbol, "@@")) {
|
||||||
for (char i = 7; i >= 0; i--) {
|
for (char i = 7; i >= 0; i--) {
|
||||||
entry->string[7 - i] = ft_get_hex_digit((sym.st_value >> i * 4) & 0xF);
|
entry->string[7 - i] = ft_get_hex_digit((sym->st_value >> i * 4) & 0xF);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ft_strcmp(sym_char, "U") && ft_strcmp(sym_char, "w") && ft_strcmp(sym_char, "v")) {
|
if (ft_strcmp(sym_char, "U") && ft_strcmp(sym_char, "w") && ft_strcmp(sym_char, "v")) {
|
||||||
|
|
||||||
for (char i = 7; i >= 0; i--) {
|
for (char i = 7; i >= 0; i--) {
|
||||||
entry->string[7 - i] = ft_get_hex_digit((sym.st_value >> i * 4) & 0xF);
|
entry->string[7 - i] = ft_get_hex_digit((sym->st_value >> i * 4) & 0xF);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
|
@ -244,7 +265,6 @@ int nm32(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_orderin
|
||||||
ft_rbt_insert(&tree, ft_rbt_new((void *)entry, sizeof(t_entry)), &strcmp_nm);
|
ft_rbt_insert(&tree, ft_rbt_new((void *)entry, sizeof(t_entry)), &strcmp_nm);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
|
||||||
} else {
|
} else {
|
||||||
free(entry->symbol);
|
free(entry->symbol);
|
||||||
free(sym_char);
|
free(sym_char);
|
||||||
|
|
Loading…
Reference in New Issue