local syms

This commit is contained in:
Jack Halford 2017-03-27 21:58:49 +02:00
parent 5eee516d3a
commit 646868b77a
14 changed files with 27 additions and 72 deletions

View file

@ -6,7 +6,7 @@
# By: jhalford <jack@crans.org> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2017/02/19 03:29:38 by jhalford #+# #+# #
# Updated: 2017/03/26 15:37:30 by jhalford ### ########.fr #
# Updated: 2017/03/27 20:21:47 by jhalford ### ########.fr #
# #
# **************************************************************************** #
@ -104,14 +104,14 @@ clean:
cleanlib:
@make -C $(LIBFT_DIR) clean
fclean: clean
fclean: clean
@$(RM) $(NAME)
@printf "\r\e[38;5;196m❌ fclean $(NAME).\e[0m\e[K\n"
fcleanlib: cleanlib
@make -C $(LIBFT_DIR) fclean
re: fclean all
re: fclean relib all
relib: fcleanlib $(LIBFT_LIB)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/20 14:36:10 by jhalford #+# #+# */
/* Updated: 2017/03/26 19:12:12 by jhalford ### ########.fr */
/* Updated: 2017/03/27 20:59:15 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -108,12 +108,11 @@ void symbol_free(void *data, size_t size);
int symbol_format(t_symbol *symbol);
int symbol_format_full(t_symbol *symbol);
int sym_format_undf(t_symbolmap map, t_symbol *symbol);
int sym_format_text(t_symbolmap map, t_symbol *symbol);
int sym_format_stab(t_symbolmap map, t_symbol *symbol);
void mach_64_parse(t_machodata *data);
void dump_dysymtab(t_machodata *data, struct dysymtab_command *dysymtab);
void *hexdump(void *addr, unsigned int offset, unsigned int size);
void *hexdump(void *addr, unsigned int offset, unsigned int size);
#endif

View file

@ -6,11 +6,12 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/19 03:09:12 by jhalford #+# #+# */
/* Updated: 2017/03/26 19:12:03 by jhalford ### ########.fr */
/* Updated: 2017/03/27 20:59:06 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_nm_otool.h"
#define NM_USAGE "usage: nm [-a]"
t_machodata *g_data = NULL;
@ -20,7 +21,7 @@ t_cliopts g_nm_opts[] =
{'p', NULL, NM_NOSORT, 0, NULL, 0},
{'r', NULL, NM_RSORT, 0, NULL, 0},
{0xff, "full", NM_FULL | NM_ALL, 0, NULL, 0},
{0xff, "full", NM_FULL, 0, NULL, 0},
{'g', NULL, 0, 0, NULL, 0},
{'u', NULL, 0, 0, NULL, 0},
{'a', NULL, NM_ALL, 0, NULL, 0},
@ -78,7 +79,7 @@ int main(int ac, char **av)
if (cliopts_get(av, g_nm_opts, &data))
{
ft_perror();
ft_dprintf(2, "USAGE PLACEHOLDER\n");
ft_dprintf(2, NM_USAGE);
return (1);
}
i = data.av_data - av;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/20 14:08:14 by jhalford #+# #+# */
/* Updated: 2017/03/26 19:10:48 by jhalford ### ########.fr */
/* Updated: 2017/03/27 20:41:01 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -47,7 +47,7 @@ void otool(void *file)
struct section_64 *sect;
if (is_fat)
ft_printf("fat binary: not supported yet.\n");
ft_printf("fat binary not supported yet\n");
else if (is_64)
{
sect = get_text_section(file);

View file

@ -1,4 +1,5 @@
/* ************************************************************************** */
/*
************************************************************************** */
/* */
/* ::: :::::::: */
/* symbol_filter.c :+: :+: :+: */

View file

@ -4,7 +4,7 @@ t_symbolmap g_symbolmap[] =
{
{'U', sym_format_undf},
{'A', NULL},
{'T', sym_format_text},
{'T', NULL},
{'D', NULL},
{'B', NULL},
{'C', NULL},
@ -20,15 +20,6 @@ int sym_format_undf(t_symbolmap map, t_symbol *symbol)
return (0);
}
int sym_format_text(t_symbolmap map, t_symbol *symbol)
{
char c;
c = symbol->nlist->n_type & N_EXT ? 'T' : 't';
ft_printf("%016llx %c %s\n", symbol->nlist->n_value, map.c, symbol->string);
return (0);
}
int sym_format_stab(t_symbolmap map, t_symbol *symbol)
{
struct nlist_64 *stab;
@ -47,7 +38,8 @@ int symbol_format_full(t_symbol *symbol)
symbol->pos,
(symbol->nlist->n_type & N_STAB) >> 5,
(symbol->nlist->n_type & N_PEXT) >> 4,
symbol->nlist->n_type & N_TYPE, symbol->nlist->n_type & N_EXT,
symbol->nlist->n_type & N_TYPE,
symbol->nlist->n_type & N_EXT,
symbol->nlist->n_sect, symbol->section->sectname,
symbol->nlist->n_desc, symbol->nlist->n_value,
symbol->string);
@ -57,6 +49,7 @@ int symbol_format_full(t_symbol *symbol)
int symbol_format(t_symbol *symbol)
{
t_symbolmap map;
char c;
map = g_symbolmap[symbol->type];
@ -64,8 +57,9 @@ int symbol_format(t_symbol *symbol)
map.format(map, symbol);
else
{
c = symbol->nlist->n_type & N_EXT ? map.c : map.c + 32;
ft_printf("%016llx %c %s\n",
symbol->nlist->n_value, map.c, symbol->string);
symbol->nlist->n_value, c, symbol->string);
}
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/25 21:22:06 by jhalford #+# #+# */
/* Updated: 2017/03/26 16:50:13 by jhalford ### ########.fr */
/* Updated: 2017/03/27 20:36:57 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -40,15 +40,15 @@ int symbol_set(t_symbol *symbol, t_machodata *data)
symbol->type = SYM_COMMON;
else if (type_mask == N_UNDF)
symbol->type = SYM_UNDF;
else if (type_mask == N_SECT && ft_strcmp("__TEXT", symbol->section->segname) == 0)
symbol->type = SYM_TEXT;
else if (type_mask == N_SECT && ft_strcmp("__DATA", symbol->section->segname) == 0)
symbol->type = SYM_DATA;
else if (type_mask == N_ABS)
symbol->type = SYM_ABS;
else if (type_mask == N_SECT && ft_strcmp("__text", symbol->section->sectname) == 0)
symbol->type = SYM_TEXT;
else if (type_mask == N_SECT && ft_strcmp("__data", symbol->section->sectname) == 0)
symbol->type = SYM_DATA;
else if (type_mask == N_INDR)
symbol->type = SYM_INDR;
else
symbol->type = SYM_UNDF;
symbol->type = SYM_OTHER;
return (0);
}

View file

@ -5,8 +5,8 @@
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/26 15:03:55 by jhalford #+# #+# */
/* Updated: 2017/03/26 19:20:49 by jhalford ### ########.fr */
/* Created: 2017/03/27 20:33:02 by jhalford #+# #+# */
/* Updated: 2017/03/27 20:33:03 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -1 +0,0 @@
gcc -g3 stabs_define.c -w -o stabs_define

View file

@ -1,23 +0,0 @@
#define NONE 42
#define TWO(a, b) (a + (a) + 2 * b)
#define ONE(c) (c + 19)
main(int argc, char *argv[])
{
func(NONE, TWO(10, 11));
func(NONE, ONE(23));
#undef ONE
#define ONE(c) (c + 23)
func(NONE, ONE(-23));
return (0);
}
int global;
func(int arg1, int arg2)
{
global = arg1 + arg2;
}

Binary file not shown.

View file

@ -1,7 +0,0 @@
#include <stdio.h>
int main(void)
{
puts("Test facile");
return (0);
}

Binary file not shown.

View file

@ -1,9 +0,0 @@
#include <stdio.h>
int une_globale = 40;
int main(void)
{
printf("La globale vaut: %d\n", une_globale);
return (0);
}