print filename
This commit is contained in:
parent
5b0cd41383
commit
3935cb38a8
3 changed files with 10 additions and 3 deletions
|
@ -6,7 +6,7 @@
|
||||||
/* By: gtertysh <gtertysh@student.unit.ua> +#+ +:+ +#+ */
|
/* By: gtertysh <gtertysh@student.unit.ua> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/05/06 22:37:16 by foton #+# #+# */
|
/* 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;
|
void *file;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
int fd;
|
int fd;
|
||||||
|
const char *filename;
|
||||||
} t_nm_file;
|
} t_nm_file;
|
||||||
|
|
||||||
typedef struct s_nm_mach_64
|
typedef struct s_nm_mach_64
|
||||||
|
|
|
@ -43,6 +43,7 @@ void print_symbol_table(t_nm_mach_64 *mach64)
|
||||||
t_section_64 *section;
|
t_section_64 *section;
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
while(j < mach64->symbol_table_command->nsyms)
|
while(j < mach64->symbol_table_command->nsyms)
|
||||||
{
|
{
|
||||||
symbol = mach64->symbol_table[j];
|
symbol = mach64->symbol_table[j];
|
||||||
|
@ -101,5 +102,8 @@ void macho64(t_nm_file *file)
|
||||||
(mach64.symbol_table_command->symoff + file->file);
|
(mach64.symbol_table_command->symoff + file->file);
|
||||||
mach64.string_table = (char *)
|
mach64.string_table = (char *)
|
||||||
(mach64.symbol_table_command->stroff + file->file);
|
(mach64.symbol_table_command->stroff + file->file);
|
||||||
|
ft_putstr("\n");
|
||||||
|
ft_putstr(file->filename);
|
||||||
|
ft_putstr(":\n");
|
||||||
print_symbol_table(&mach64);
|
print_symbol_table(&mach64);
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@ void init_file(t_nm_file *file)
|
||||||
{
|
{
|
||||||
file->fd = -1;
|
file->fd = -1;
|
||||||
file->file = NULL;
|
file->file = NULL;
|
||||||
|
file->filename = NULL;
|
||||||
file->size = 0;
|
file->size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,16 +20,17 @@ void open_file(const char *filename, t_nm_file *file)
|
||||||
{
|
{
|
||||||
struct stat stat_buff;
|
struct stat stat_buff;
|
||||||
|
|
||||||
|
file->filename = filename;
|
||||||
file->fd = open(filename, O_RDONLY);
|
file->fd = open(filename, O_RDONLY);
|
||||||
if (file->fd == -1)
|
if (file->fd == -1)
|
||||||
{
|
{
|
||||||
ft_putstr("can't open file\n");
|
perror(filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
stat(filename, &stat_buff);
|
stat(filename, &stat_buff);
|
||||||
if (!S_ISREG(stat_buff.st_mode))
|
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);
|
close(file->fd);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue