diff --git a/inc/ft_nm.h b/inc/ft_nm.h index 5489f69..d80649d 100644 --- a/inc/ft_nm.h +++ b/inc/ft_nm.h @@ -6,7 +6,7 @@ /* By: gtertysh +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/05/06 22:37:16 by foton #+# #+# */ -/* Updated: 2019/07/20 15:38:47 by gtertysh ### ########.fr */ +/* Updated: 2019/07/20 16:17:47 by gtertysh ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,6 +28,7 @@ typedef struct s_nm_file void *file; uint32_t size; int fd; + const char *filename; } t_nm_file; typedef struct s_nm_mach_64 diff --git a/src/macho64.c b/src/macho64.c index 80ae805..d8797c5 100644 --- a/src/macho64.c +++ b/src/macho64.c @@ -43,6 +43,7 @@ void print_symbol_table(t_nm_mach_64 *mach64) t_section_64 *section; j = 0; + while(j < mach64->symbol_table_command->nsyms) { symbol = mach64->symbol_table[j]; @@ -101,5 +102,8 @@ void macho64(t_nm_file *file) (mach64.symbol_table_command->symoff + file->file); mach64.string_table = (char *) (mach64.symbol_table_command->stroff + file->file); + ft_putstr("\n"); + ft_putstr(file->filename); + ft_putstr(":\n"); print_symbol_table(&mach64); } \ No newline at end of file diff --git a/src/nm_file.c b/src/nm_file.c index a0aaef2..d863128 100644 --- a/src/nm_file.c +++ b/src/nm_file.c @@ -12,6 +12,7 @@ void init_file(t_nm_file *file) { file->fd = -1; file->file = NULL; + file->filename = NULL; file->size = 0; } @@ -19,16 +20,17 @@ void open_file(const char *filename, t_nm_file *file) { struct stat stat_buff; + file->filename = filename; file->fd = open(filename, O_RDONLY); if (file->fd == -1) { - ft_putstr("can't open file\n"); + perror(filename); exit(1); } stat(filename, &stat_buff); if (!S_ISREG(stat_buff.st_mode)) { - ft_putstr("not a regular file\n"); + ft_putstr_fd("not a regular file\n", STDERR_FILENO); close(file->fd); exit(1); }