diff --git a/--force b/--force new file mode 160000 index 0000000..d2d5c96 --- /dev/null +++ b/--force @@ -0,0 +1 @@ +Subproject commit d2d5c969e820e0350d1d70c2977e2b6b1f48e5a5 diff --git a/.cache/clangd/index/ft_printf.h.E66E29B51655512D.idx b/.cache/clangd/index/ft_printf.h.E66E29B51655512D.idx index 2f2e3d9..8fa88f7 100644 Binary files a/.cache/clangd/index/ft_printf.h.E66E29B51655512D.idx and b/.cache/clangd/index/ft_printf.h.E66E29B51655512D.idx differ diff --git a/.cache/clangd/index/libft.h.4AAB37F6DDB83F16.idx b/.cache/clangd/index/libft.h.4AAB37F6DDB83F16.idx index 3a5e16a..7db2991 100644 Binary files a/.cache/clangd/index/libft.h.4AAB37F6DDB83F16.idx and b/.cache/clangd/index/libft.h.4AAB37F6DDB83F16.idx differ diff --git a/.cache/clangd/index/main.c.3F920B18C55EC32E.idx b/.cache/clangd/index/main.c.3F920B18C55EC32E.idx index 703e0cd..d726a08 100644 Binary files a/.cache/clangd/index/main.c.3F920B18C55EC32E.idx and b/.cache/clangd/index/main.c.3F920B18C55EC32E.idx differ diff --git a/Makefile b/Makefile index 855c5d5..46bdeff 100644 --- a/Makefile +++ b/Makefile @@ -5,28 +5,31 @@ PRINTF=lib/libftprintf.a all: $(NAME) $(NAME): $(PRINTF) - @gcc -Wall -Wextra -Werror -o $(NAME) main.c nm/nm32.c nm/nm64.c nm/is.c -I includes -L lib -lftprintf + gcc -Wall -Wextra -Werror -o $(NAME) main.c nm/nm32.c nm/nm64.c nm/is.c -I includes -L lib -lftprintf $(PRINTF): - @make -C ft_printf + make -C ft_printf cp ft_printf/libftprintf.a lib/ - cp ft_printf/libft/libft.h includes/ - cp ft_printf/ft_printf.h includes/ + cp ft_printf/includes/libft.h includes/ + cp ft_printf/includes/ft_printf.h includes/ tests: - @./testster.sh + ./testster.sh debug: - @gcc -Wall -Wextra -Werror -g -o $(NAME) main.c nm/nm32.c nm/nm64.c nm/is.c -I includes + gcc -Wall -Wextra -Werror -g -o $(NAME) main.c nm/nm32.c nm/nm64.c nm/is.c -I includes readelf: - @gcc -DREADELF -g -Wall -Wextra -Werror -o ft_re main.c re/re32.c re/re64.c re/gets.c -I includes + gcc -DREADELF -g -Wall -Wextra -Werror -o ft_re main.c re/re32.c re/re64.c re/gets.c -I includes clean: - @rm -rf ./exterminatests/*/*/logs - @rm -f $(NAME) + ${MAKE} -C ft_printf clean + rm -rf ./exterminatests/*/*/logs + rm -f $(NAME) fclean: clean + ${MAKE} -C ft_printf fclean + rm -rf lib/libftprintf.a re: fclean all diff --git a/ft_printf b/ft_printf index 55944fc..d2d5c96 160000 --- a/ft_printf +++ b/ft_printf @@ -1 +1 @@ -Subproject commit 55944fc02b4309928c94b6be904beebf315b7985 +Subproject commit d2d5c969e820e0350d1d70c2977e2b6b1f48e5a5 diff --git a/includes/ft_printf.h b/includes/ft_printf.h index 346dd4f..7e1dada 100644 --- a/includes/ft_printf.h +++ b/includes/ft_printf.h @@ -16,7 +16,7 @@ # include "libft.h" # include - +# include typedef struct s_opts { int len; @@ -30,19 +30,30 @@ typedef struct s_opts { int plus : 1; } t_opts; + +void add_string(char *str, size_t size); +t_dlist *get_last(void); +t_dlist *get_first(void); +void clean_list(void); + char *int_opts_transform(int n, char *nbr, t_opts *opts); char *uint_opts_transform(unsigned int n, char *nbr, t_opts *opts); char *ptr_opts_transform(char *ptr, t_opts *opts); char *str_opts_transform(char *str, t_opts *opts); -int ft_print_char(int ch, t_opts *opts); -int ft_print_str(char *str, t_opts *opts); -int va_print_char(va_list va_ch, const char *str, t_opts *opts); -int va_print_str(va_list va_str, const char *str, t_opts *opts); -int va_print_ptr(va_list va_ptr, const char *str, t_opts *opts); -int va_print_nbr(va_list va_int, const char *str, t_opts *opts); -int va_print_unsign(va_list va_uint, const char *str, t_opts *opts); -int va_print_x(va_list va_uint, const char *str, t_opts *opts); -int va_print_x_cap(va_list va_uint, const char *str, t_opts *opts); -int va_print_perc(va_list va, const char *str, t_opts *opts); +void ft_print_char(int ch, t_opts *opts); +void ft_print_str(char *str, t_opts *opts); +void va_print_char(va_list va_ch, const char *str, t_opts *opts); +void va_print_str(va_list va_str, const char *str, t_opts *opts); +void va_print_ptr(va_list va_ptr, const char *str, t_opts *opts); +void va_print_nbr(va_list va_int, const char *str, t_opts *opts); +void va_print_unsign(va_list va_uint, const char *str, t_opts *opts); +void va_print_x(va_list va_uint, const char *str, t_opts *opts); +void va_print_x_cap(va_list va_uint, const char *str, t_opts *opts); +void va_print_perc(va_list va, const char *str, t_opts *opts); + +void ft_format(const char *str, va_list args); + int ft_printf(const char *str, ...); +int ft_fprintf(FILE *file, const char *format, ...); +int ft_sprintf(char *ret, const char *format, ...); diff --git a/includes/ft_re.h b/includes/ft_re.h index 5f3e6d7..b185b83 100644 --- a/includes/ft_re.h +++ b/includes/ft_re.h @@ -5,6 +5,8 @@ #include "ctype.h" #include "unistd.h" +#include "ft_printf.h" + int ft_re32(char *filename, int filesize, char *file, t_opts opts); int ft_re64(char *filename, int filesize, char *file, t_opts opts); diff --git a/includes/libft.h b/includes/libft.h index 20b31d4..14abb23 100755 --- a/includes/libft.h +++ b/includes/libft.h @@ -31,6 +31,7 @@ typedef struct s_i_slist typedef struct s_dlist { void *content; + size_t size; struct s_dlist *next; struct s_dlist *previous; } t_dlist; @@ -84,6 +85,7 @@ char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); void ft_striteri(char *s, void (*f)(unsigned int, char*)); void ft_putchar_fd(char c, int fd); void ft_putstr_fd(char *s, int fd); +void ft_putnstr_fd(size_t n, char *s, int fd); void ft_putendl_fd(char *s, int fd); void ft_putnbr_fd(int n, int fd); char *ft_append(char *s1, char *s2); diff --git a/lib/libftprintf.a b/lib/libftprintf.a deleted file mode 100644 index 12c7afe..0000000 Binary files a/lib/libftprintf.a and /dev/null differ diff --git a/main.c b/main.c index 7e38bd9..45e5827 100644 --- a/main.c +++ b/main.c @@ -51,12 +51,13 @@ int get_filename_pos(char **argv) { } int is_valid_file(char *file) { - return file[EI_MAG0] == ELFMAG0 && file[EI_MAG1] == ELFMAG1 && file[EI_MAG2] == ELFMAG2 && file[EI_MAG3] == ELFMAG3 - && (file[EI_CLASS] == ELFCLASS32 || file[EI_CLASS] == ELFCLASS64) - && (file[EI_DATA] == ELFDATA2LSB || file[EI_DATA] == ELFDATA2MSB) - && (file[EI_VERSION] == EV_CURRENT) - && (file[16] == ET_REL || file[16] == ET_EXEC || file[16] == ET_DYN) - && (file[18] == EM_386 || file[18] == 6 || file[18] == EM_X86_64); + return file[EI_MAG0] == ELFMAG0 && file[EI_MAG1] == ELFMAG1 && file[EI_MAG2] == ELFMAG2 && + file[EI_MAG3] == ELFMAG3 && + (file[EI_CLASS] == ELFCLASS32 || file[EI_CLASS] == ELFCLASS64) && + (file[EI_DATA] == ELFDATA2LSB || file[EI_DATA] == ELFDATA2MSB) && + (file[EI_VERSION] == EV_CURRENT) && + (file[16] == ET_REL || file[16] == ET_EXEC || file[16] == ET_DYN) && + (file[18] == EM_386 || file[18] == 6 || file[18] == EM_X86_64); } int main(int argc, char **argv) { @@ -69,17 +70,21 @@ int main(int argc, char **argv) { if ((fd = open(filename, O_RDONLY)) < 0) return (perror("open"), EXIT_FAILURE); if (fstat(fd, &buf) < 0) return (perror("fstat"), EXIT_FAILURE); - if (S_ISDIR(buf.st_mode)) return (fprintf(stderr, "nm: Attention : « %s » est un répertoire\n", filename), EXIT_FAILURE); + if (S_ISDIR(buf.st_mode)) + return (ft_fprintf(stderr, "nm: Attention : « %s » est un répertoire\n", filename), + EXIT_FAILURE); file = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (is_valid_file(file)) { - if (file[EI_CLASS] == ELFCLASS32 ) ret = LAUNCH32; + if (file[EI_CLASS] == ELFCLASS32) ret = LAUNCH32; else if (file[EI_CLASS] == ELFCLASS64) ret = LAUNCH64; else ret = -1; } else ret = -1; - //printf("%d %d %d %d %d %d %d %d %d %d %d %d %d", file[8], file[9], file[10], file[11], file[12], file[13], file[14], file[15], file[16], file[17], file[18], file[19], file[20]); - if (ret == -3)fprintf(stderr, "bfd plugin: %s: file too short\n", filename); - if (ret == -1 || ret == -3) fprintf(stderr, "nm: %s: format de fichier non reconnu\n", filename); - if (ret == -2) fprintf(stderr, "nm: %s: aucun symbole\n", filename); + // printf("%d %d %d %d %d %d %d %d %d %d %d %d %d", file[8], file[9], file[10], file[11], + // file[12], file[13], file[14], file[15], file[16], file[17], file[18], file[19], file[20]); + if (ret == -3) ft_fprintf(stderr, "bfd plugin: %s: file too short\n", filename); + if (ret == -1 || ret == -3) + ft_fprintf(stderr, "nm: %s: format de fichier non reconnu\n", filename); + if (ret == -2) ft_fprintf(stderr, "nm: %s: aucun symbole\n", filename); if (munmap(file, buf.st_size) < 0) return (perror("munmap"), EXIT_FAILURE); return (close(fd), EXIT_SUCCESS); } diff --git a/re/re32.c b/re/re32.c index c2cce14..4f3aca0 100644 --- a/re/re32.c +++ b/re/re32.c @@ -1,85 +1,85 @@ #include "ft_re.h" -void display_32_section_header(t_elf32 *nm, int i) { - printf( +voi display_32_section_header(t_elf32 *nm, int i) { + ft_printf( " [Nr] Name Type Addr Off Size " " " "ES Flg Lk Inf Al\n"); - printf(" [%2d] ", i); - printf("%-18s", nm->string_table + nm->shdr[i].sh_name); - printf("%-8s", get_section_type(nm->shdr[i].sh_type)); - printf("%08x ", nm->shdr[i].sh_addr); - printf("%06x ", nm->shdr[i].sh_offset); - printf("%06x ", nm->shdr[i].sh_size); - printf("%02x ", nm->shdr[i].sh_entsize); - printf("%3s ", get_section_flags(nm->shdr[i].sh_flags)); - printf("%02x ", nm->shdr[i].sh_link); - printf("%02x ", nm->shdr[i].sh_info); - printf("%02x\n", nm->shdr[i].sh_addralign); + ft_printf(" [%2d] ", i); + ft_printf("%-18s", nm->string_table + nm->shdr[i].sh_name); + ft_printf("%-8s", get_section_type(nm->shdr[i].sh_type)); + ft_printf("%08x ", nm->shdr[i].sh_addr); + ft_printf("%06x ", nm->shdr[i].sh_offset); + ft_printf("%06x ", nm->shdr[i].sh_size); + ft_printf("%02x ", nm->shdr[i].sh_entsize); + ft_printf("%3s ", get_section_flags(nm->shdr[i].sh_flags)); + ft_printf("%02x ", nm->shdr[i].sh_link); + ft_printf("%02x ", nm->shdr[i].sh_info); + ft_printf("%02x\n", nm->shdr[i].sh_addralign); } void display_32_header(t_elf32 *nm) { - printf("ELF Header:\n"); - printf(" Magic: "); - for (int i = 0; i < EI_NIDENT; i++) printf("%02x ", nm->ehdr->e_ident[i]); - printf("\n Class: ELF32\n"); - printf( + ft_printf("ELF Header:\n"); + ft_printf(" Magic: "); + for (int i = 0; i < EI_NIDENT; i++)ft_printf("%02x ", nm->ehdr->e_ident[i]); + ft_printf("\n Class: ELF32\n"); + ft_printf( " Data: 2's complement, little endian\n"); - printf(" Version: 1 (current)\n"); - printf(" OS/ABI: UNIX - System V\n"); - printf(" ABI Version: 0\n"); - printf(" Version: 0x%08x\n", + ft_printf(" Version: 1 (current)\n"); + ft_printf(" OS/ABI: UNIX - System V\n"); + ft_printf(" ABI Version: 0\n"); + ft_printf(" Version: 0x%08x\n", nm->ehdr->e_version); - printf(" Entry point address: 0x%08x\n", + ft_printf(" Entry point address: 0x%08x\n", nm->ehdr->e_entry); - printf(" Start of program headers: %d (bytes into file)\n", + ft_printf(" Start of program headers: %d (bytes into file)\n", nm->ehdr->e_phoff); - printf(" Start of section headers: %d (bytes into file)\n", + ft_printf(" Start of section headers: %d (bytes into file)\n", nm->ehdr->e_shoff); - printf(" Flags: 0x%08x\n", nm->ehdr->e_flags); - printf(" Size of this header: %d (bytes)\n", + ft_printf(" Flags: 0x%08x\n", nm->ehdr->e_flags); + ft_printf(" Size of this header: %d (bytes)\n", nm->ehdr->e_ehsize); - printf(" Size of program headers: %d (bytes)\n", + ft_printf(" Size of program headers: %d (bytes)\n", nm->ehdr->e_phentsize); - printf(" Number of program headers: %d\n", nm->ehdr->e_phnum); - printf(" Size of section headers: %d (bytes)\n", + ft_printf(" Number of program headers: %d\n", nm->ehdr->e_phnum); + ft_printf(" Size of section headers: %d (bytes)\n", nm->ehdr->e_shentsize); - printf(" Number of section headers: %d\n", nm->ehdr->e_shnum); - printf(" Section header string table index: %d\n", nm->ehdr->e_shstrndx); + ft_printf(" Number of section headers: %d\n", nm->ehdr->e_shnum); + ft_printf(" Section header string table index: %d\n", nm->ehdr->e_shstrndx); } int print_32_symtab(t_elf32 *nm) { int sym_num = nm->symtab_end - nm->symtab; - printf("Symbol table '%s' contains %d entries:\n", nm->file, sym_num); - printf("Contents of the (%s) section: \n", + ft_printf("Symbol table '%s' contains %d entries:\n", nm->file, sym_num); + ft_printf("Contents of the (%s) section: \n", nm->string_table + nm->shdr[nm->ehdr->e_shstrndx].sh_name); - printf( + ft_printf( "| Num: |Value |Size |Type |Bind |Vis " " |Ndx0x |Ndx " " |shndxty |shndxfl|nmChar |Name\n"); for (int i = 0; i < sym_num; i++) { int id = nm->opts.p == 0 ? nm->ordered_sym_ids[i] : i; - printf("| %4d: ", id); - printf("|%8x ", nm->symtab[id].st_value); - printf("|%8x ", nm->symtab[id].st_size); - printf("|%-6s ", get_sym_type(ELF32_ST_TYPE(nm->symtab[id].st_info))); - printf("|%-6s ", get_sym_bind(ELF32_ST_BIND(nm->symtab[id].st_info))); - printf("|%-7s ", + ft_printf("| %4d: ", id); + ft_printf("|%8x ", nm->symtab[id].st_value); + ft_printf("|%8x ", nm->symtab[id].st_size); + ft_printf("|%-6s ", get_sym_type(ELF32_ST_TYPE(nm->symtab[id].st_info))); + ft_printf("|%-6s ", get_sym_bind(ELF32_ST_BIND(nm->symtab[id].st_info))); + ft_printf("|%-7s ", get_sym_vis(ELF32_ST_VISIBILITY(nm->symtab[id].st_other))); - printf("|%5d", nm->symtab[id].st_shndx); - printf("|%7s ", get_sym_shndx(nm->symtab[id].st_shndx)); + ft_printf("|%5d", nm->symtab[id].st_shndx); + ft_printf("|%7s ", get_sym_shndx(nm->symtab[id].st_shndx)); if (nm->symtab[id].st_shndx < nm->ehdr->e_shnum) { - printf("|%8s", + ft_printf("|%8s", get_sh_type(nm->shdr[nm->symtab[id].st_shndx].sh_type)); - printf("|%8s", + ft_printf("|%8s", get_sh_flag(nm->shdr[nm->symtab[id].st_shndx].sh_flags)); } else { - printf("|%8c", ' '); - printf("|%8c", ' '); + ft_printf("|%8c", ' '); + ft_printf("|%8c", ' '); } - printf("|%6c ", nm->sym_types[id]); - printf("|%s\n", nm->sym_names[id]); + ft_printf("|%6c ", nm->sym_types[id]); + ft_printf("|%s\n", nm->sym_names[id]); } return 1; } @@ -97,7 +97,7 @@ int ft_re32(char *filename, int filesize, char *file, t_opts opts) { // check if file is complete if (nm.ehdr->e_shoff + nm.ehdr->e_shnum * nm.ehdr->e_shentsize > nm.size) { - fprintf(stderr, "bfd plugin: %s: file too short\n", nm.file); + ft_fprintf(stderr, "bfd plugin: %s: file too short\n", nm.file); return -1; } diff --git a/re/re64.c b/re/re64.c index b5ace28..6c8b5f4 100644 --- a/re/re64.c +++ b/re/re64.c @@ -1,90 +1,90 @@ #include "ft_re.h" void display_64_section_header(t_elf64 *nm, int i) { - printf( + ft_printf( " [Nr] Name Type Addr Off Size " " " "ES Flg Lk Inf Al\n"); - printf(" [%2d] ", i); - printf("%-18s", nm->string_table + nm->shdr[i].sh_name); - printf("%-16s", get_section_type(nm->shdr[i].sh_type)); - printf("%016lx ", nm->shdr[i].sh_addr); - printf("%06lx ", nm->shdr[i].sh_offset); - printf("%06lx ", nm->shdr[i].sh_size); - printf("%02lx ", nm->shdr[i].sh_entsize); - printf("%3s ", get_section_flags(nm->shdr[i].sh_flags)); - printf("%02x ", nm->shdr[i].sh_link); - printf("%02x ", nm->shdr[i].sh_info); - printf("%02lx\n", nm->shdr[i].sh_addralign); + ft_printf(" [%2d] ", i); + ft_printf("%-18s", nm->string_table + nm->shdr[i].sh_name); + ft_printf("%-16s", get_section_type(nm->shdr[i].sh_type)); + ft_printf("%016lx ", nm->shdr[i].sh_addr); + ft_printf("%06lx ", nm->shdr[i].sh_offset); + ft_printf("%06lx ", nm->shdr[i].sh_size); + ft_printf("%02lx ", nm->shdr[i].sh_entsize); + ft_printf("%3s ", get_section_flags(nm->shdr[i].sh_flags)); + ft_printf("%02x ", nm->shdr[i].sh_link); + ft_printf("%02x ", nm->shdr[i].sh_info); + ft_printf("%02lx\n", nm->shdr[i].sh_addralign); } void display_64_header(t_elf64 *nm) { - printf("ELF Header:\n"); - printf(" Magic: "); - for (int i = 0; i < EI_NIDENT; i++) printf("%02x ", nm->ehdr->e_ident[i]); - printf("\n Class: ELF64\n"); - printf( + ft_printf("ELF Header:\n"); + ft_printf(" Magic: "); + for (int i = 0; i < EI_NIDENT; i++)ft_printf("%02x ", nm->ehdr->e_ident[i]); + ft_printf("\n Class: ELF64\n"); + ft_printf( " Data: 2's complement, little endian\n"); - printf(" Version: 1 (current)\n"); - printf(" OS/ABI: UNIX - System V\n"); - printf(" ABI Version: 0\n"); - printf(" Version: 0x%016x\n", + ft_printf(" Version: 1 (current)\n"); + ft_printf(" OS/ABI: UNIX - System V\n"); + ft_printf(" ABI Version: 0\n"); + ft_printf(" Version: 0x%016x\n", nm->ehdr->e_version); - printf(" Entry point address: 0x%016lx\n", + ft_printf(" Entry point address: 0x%016lx\n", nm->ehdr->e_entry); - printf(" Start of program headers: %ld (bytes into file)\n", + ft_printf(" Start of program headers: %ld (bytes into file)\n", nm->ehdr->e_phoff); - printf(" Start of section headers: %ld (bytes into file)\n", + ft_printf(" Start of section headers: %ld (bytes into file)\n", nm->ehdr->e_shoff); - printf(" Flags: 0x%016x\n", nm->ehdr->e_flags); - printf(" Size of this header: %d (bytes)\n", + ft_printf(" Flags: 0x%016x\n", nm->ehdr->e_flags); + ft_printf(" Size of this header: %d (bytes)\n", nm->ehdr->e_ehsize); - printf(" Size of program headers: %d (bytes)\n", + ft_printf(" Size of program headers: %d (bytes)\n", nm->ehdr->e_phentsize); - printf(" Number of program headers: %d\n", nm->ehdr->e_phnum); - printf(" Size of section headers: %d (bytes)\n", + ft_printf(" Number of program headers: %d\n", nm->ehdr->e_phnum); + ft_printf(" Size of section headers: %d (bytes)\n", nm->ehdr->e_shentsize); - printf(" Number of section headers: %d\n", nm->ehdr->e_shnum); - printf(" Section header string table index: %d\n", nm->ehdr->e_shstrndx); + ft_printf(" Number of section headers: %d\n", nm->ehdr->e_shnum); + ft_printf(" Section header string table index: %d\n", nm->ehdr->e_shstrndx); } int print_64_symtab(t_elf64 *nm) { int sym_num = nm->symtab_end - nm->symtab; - printf("Symbol table '%s' contains %d entries:\n", nm->file, sym_num); - printf("Contents of the (%s) section: \n", + ft_printf("Symbol table '%s' contains %d entries:\n", nm->file, sym_num); + ft_printf("Contents of the (%s) section: \n", nm->string_table + nm->shdr[nm->ehdr->e_shstrndx].sh_name); - printf( + ft_printf( "| Num: |Value |Size |Type |Bind |Vis " " |Ndx0x |Ndx " " |shndxty |shndxfl|nmChar |Name\n"); for (int i = 0; i < sym_num; i++) { int id = nm->opts.p == 0 ? nm->ordered_sym_ids[i] : i; - printf("| %4d: ", id); - printf("|%16lx ", nm->symtab[id].st_value); - printf("|%16lx ", nm->symtab[id].st_size); - printf("|%-6s ", get_sym_type(ELF64_ST_TYPE(nm->symtab[id].st_info))); - printf("|%-6s ", get_sym_bind(ELF64_ST_BIND(nm->symtab[id].st_info))); - printf("|%-7s ", + ft_printf("| %4d: ", id); + ft_printf("|%16lx ", nm->symtab[id].st_value); + ft_printf("|%16lx ", nm->symtab[id].st_size); + ft_printf("|%-6s ", get_sym_type(ELF64_ST_TYPE(nm->symtab[id].st_info))); + ft_printf("|%-6s ", get_sym_bind(ELF64_ST_BIND(nm->symtab[id].st_info))); + ft_printf("|%-7s ", get_sym_vis(ELF64_ST_VISIBILITY(nm->symtab[id].st_other))); - printf("|%5d", nm->symtab[id].st_shndx); - printf("|%7s ", get_sym_shndx(nm->symtab[id].st_shndx)); + ft_printf("|%5d", nm->symtab[id].st_shndx); + ft_printf("|%7s ", get_sym_shndx(nm->symtab[id].st_shndx)); if (nm->symtab[id].st_shndx < nm->ehdr->e_shnum) { - printf("|%8s", + ft_printf("|%8s", get_sh_type(nm->shdr[nm->symtab[id].st_shndx].sh_type)); - printf("|%8s", + ft_printf("|%8s", get_sh_flag(nm->shdr[nm->symtab[id].st_shndx].sh_flags)); } else { - printf("|%8c", ' '); - printf("|%8c", ' '); + ft_printf("|%8c", ' '); + ft_printf("|%8c", ' '); } - printf("|%6c ", nm->sym_types[id]); - printf("|%s\n", nm->sym_names[id]); + ft_printf("|%6c ", nm->sym_types[id]); + ft_printf("|%s\n", nm->sym_names[id]); } return 1; } -int parse_64_symtab(t_elf64 *nm) { +nt parse_64_symtab(t_elf64 *nm) { Elf64_Shdr *shdr = &nm->shdr[nm->ehdr->e_shstrndx]; nm->string_table = (char *)(nm->ptr + shdr->sh_offset); for (int i = 0; i < nm->ehdr->e_shnum; i++) { @@ -136,7 +136,7 @@ int ft_re64(char *filename, int filesize, char *file, t_opts opts) { // check if file is complete if (nm.ehdr->e_shoff + nm.ehdr->e_shnum * nm.ehdr->e_shentsize > nm.size) { - fprintf(stderr, "bfd plugin: %s: file too short\n", nm.file); + ft_fprintf(stderr, "bfd plugin: %s: file too short\n", nm.file); return -1; }