norme
This commit is contained in:
parent
3301d5880c
commit
b78cb8431a
13 changed files with 55 additions and 55 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/30 11:44:40 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 11:57:35 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 16:02:11 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -52,6 +52,7 @@
|
|||
# define NM_OFORMAT (1 << 9)
|
||||
# define NM_MFORMAT (1 << 10)
|
||||
|
||||
typedef struct s_fdata t_fdata;
|
||||
typedef enum e_symtype t_symtype;
|
||||
typedef struct s_symbolmap t_symbolmap;
|
||||
typedef struct s_machodata t_machodata;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/20 14:36:10 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 15:13:41 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 16:02:32 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -26,14 +26,21 @@
|
|||
# include <mach-o/fat.h>
|
||||
# include <mach-o/arch.h>
|
||||
|
||||
typedef unsigned int t_u;
|
||||
# include "ft_nm.h"
|
||||
# include "ft_otool.h"
|
||||
|
||||
# include "mach_64.h"
|
||||
# include "mach.h"
|
||||
# include "ppc.h"
|
||||
|
||||
typedef struct s_fdata t_fdata;
|
||||
typedef unsigned int t_u;
|
||||
|
||||
# define IS_MACH_64(x) (*(t_u*)x == MH_MAGIC_64||*(t_u*)x == MH_CIGAM_64)
|
||||
# define IS_MACH_32(x) (*(t_u*)x == MH_MAGIC||*(t_u*)x == MH_CIGAM)
|
||||
# define IS_FAT(x) (*(t_u*)x == FAT_MAGIC||*(t_u*)x == FAT_CIGAM)
|
||||
# define IS_REV(x) ({t_u m=*(t_u*)x;m==MH_CIGAM||m==MH_CIGAM_64||m==FAT_CIGAM;})
|
||||
# define MC(ptr) memcheck(data->file, ptr, sizeof(ptr), __FUNCTION__, __LINE__)
|
||||
# define MC(ptr) memcheck(data->file, ptr, sizeof(ptr))
|
||||
|
||||
struct s_fdata
|
||||
{
|
||||
|
|
@ -44,17 +51,8 @@ struct s_fdata
|
|||
char *filename;
|
||||
};
|
||||
|
||||
# include "ft_nm.h"
|
||||
# include "ft_otool.h"
|
||||
|
||||
# include "mach_64.h"
|
||||
# include "mach.h"
|
||||
# include "ppc.h"
|
||||
|
||||
uint64_t endian(uint64_t n, uint8_t size);
|
||||
|
||||
void *fat_extract(struct fat_header *fat, char *aname);
|
||||
/* void memcheck(t_fdata *file, void *ptr, size_t size); */
|
||||
void memcheck(t_fdata *file, void *ptr, size_t size, const char *function, int line);
|
||||
uint64_t endian(uint64_t n, uint8_t size);
|
||||
void memcheck(t_fdata *file, void *ptr, size_t size);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* mach.h :+: :+: :+: */
|
||||
/* mach.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/26 18:39:31 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 15:26:18 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 16:02:46 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,13 +14,14 @@
|
|||
# define MACH_H
|
||||
|
||||
typedef struct s_symbol t_symbol;
|
||||
typedef struct s_fdata t_fdata;
|
||||
|
||||
struct s_symbol
|
||||
{
|
||||
int pos;
|
||||
t_symtype type;
|
||||
char *string;
|
||||
struct nlist nlist;
|
||||
int pos;
|
||||
t_symtype type;
|
||||
char *string;
|
||||
struct nlist nlist;
|
||||
struct section *section;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/26 18:39:31 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 15:26:18 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 16:01:54 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MACH_64_H
|
||||
# define MACH_64_H
|
||||
|
||||
typedef struct s_fdata t_fdata;
|
||||
typedef struct s_symbol_64 t_symbol_64;
|
||||
|
||||
struct s_symbol_64
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/30 16:31:48 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 14:29:26 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 15:55:03 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
void *fat_extract(struct fat_header *fat, char *aname)
|
||||
{
|
||||
uint32_t narch;
|
||||
struct fat_arch *obj;
|
||||
uint32_t narch;
|
||||
struct fat_arch *obj;
|
||||
const NXArchInfo *arch;
|
||||
|
||||
narch = endian(fat->nfat_arch, 32);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* get_section.c :+: :+: :+: */
|
||||
/* get_section.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/30 11:00:40 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 15:26:47 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 15:55:25 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
void *get_segment(t_machodata *data, char *lookup)
|
||||
{
|
||||
uint32_t i;
|
||||
struct load_command *lc;
|
||||
uint32_t i;
|
||||
struct load_command *lc;
|
||||
struct segment_command *seg;
|
||||
uint32_t ncmds;
|
||||
uint32_t ncmds;
|
||||
|
||||
MC(lc = (void*)((struct mach_header*)data->file->file + 1));
|
||||
i = -1;
|
||||
|
|
@ -37,9 +37,9 @@ void *get_segment(t_machodata *data, char *lookup)
|
|||
|
||||
void *get_section(t_machodata *data, char *lookup)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t j;
|
||||
struct load_command *lc;
|
||||
uint32_t i;
|
||||
uint32_t j;
|
||||
struct load_command *lc;
|
||||
struct segment_command *seg;
|
||||
struct section *sect;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* mach.c :+: :+: :+: */
|
||||
/* mach.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/23 16:06:44 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 15:29:43 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 15:56:16 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -35,8 +35,8 @@ static void symtab_parse(t_machodata *data, struct symtab_command *symtab)
|
|||
|
||||
static void seg_parse(t_machodata *data, struct segment_command *seg)
|
||||
{
|
||||
uint32_t nsects;
|
||||
uint32_t i;
|
||||
uint32_t nsects;
|
||||
uint32_t i;
|
||||
struct section *sect;
|
||||
|
||||
nsects = endian(seg->nsects, 32);
|
||||
|
|
@ -51,9 +51,9 @@ static void seg_parse(t_machodata *data, struct segment_command *seg)
|
|||
|
||||
void mach_parse(t_machodata *data)
|
||||
{
|
||||
uint32_t ncmds;
|
||||
uint32_t i;
|
||||
struct load_command *lc;
|
||||
uint32_t ncmds;
|
||||
uint32_t i;
|
||||
struct load_command *lc;
|
||||
struct mach_header *header;
|
||||
|
||||
header = data->file->file;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* otool_mach.c :+: :+: :+: */
|
||||
/* otool_mach.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/30 11:04:06 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 15:27:26 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 15:55:48 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ extern int g_rev;
|
|||
void otool_mach(t_fdata *data)
|
||||
{
|
||||
struct section *sect;
|
||||
t_machodata mach;
|
||||
t_machodata mach;
|
||||
|
||||
mach.file = data;
|
||||
if (data->flag & OTOOL_TEXT)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* symbol_filter.c :+: :+: :+: */
|
||||
/* symbol_filter.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/26 18:31:27 by jhalford #+# #+# */
|
||||
/* Updated: 2017/10/31 16:36:55 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 15:56:29 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* symbol_format.c :+: :+: :+: */
|
||||
/* symbol_format.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/11/01 12:37:07 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 13:57:06 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 15:56:43 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* symbol_init.c :+: :+: :+: */
|
||||
/* symbol_init.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/26 18:07:28 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 15:30:01 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 15:56:57 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/23 16:06:44 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 15:29:43 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 15:57:12 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -22,7 +22,8 @@ static void symtab_64_parse(t_machodata *data, struct symtab_command *symtab)
|
|||
|
||||
data->symtab = symtab;
|
||||
MC(stringtable = data->file->file + endian(symtab->stroff, 32));
|
||||
MC(array = (struct nlist_64*)(data->file->file + endian(symtab->symoff, 32)));
|
||||
MC(array = (struct nlist_64*)(data->file->file
|
||||
+ endian(symtab->symoff, 32)));
|
||||
nsyms = endian(symtab->nsyms, 32);
|
||||
i = -1;
|
||||
while (++i < nsyms)
|
||||
|
|
|
|||
|
|
@ -6,19 +6,17 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/11/07 11:24:09 by jhalford #+# #+# */
|
||||
/* Updated: 2017/11/07 15:19:34 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/07 15:57:51 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_nm_otool.h"
|
||||
|
||||
void memcheck(t_fdata *file, void *ptr, size_t size, const char *function, int line)
|
||||
void memcheck(t_fdata *file, void *ptr, size_t size)
|
||||
{
|
||||
if (ptr <= file->file || (ptr + size) >= file->eof)
|
||||
{
|
||||
ft_dprintf(2, "%s:%i ", function, line);
|
||||
ft_dprintf(2, "%s: is corrupted\n", file->filename);
|
||||
ft_dprintf(2, "%p - %p (%zu) - %p --> %zu after end\n", file->file, ptr, size, file->eof, ptr - file->eof);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue