Skip to content

Commit

Permalink
Merge pull request #1 from Arinerron/main
Browse files Browse the repository at this point in the history
github is weird
  • Loading branch information
mysterywave authored Oct 15, 2021
2 parents 456b8f7 + 521c926 commit b58df01
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ void start_debugger(char *chargv[]) {
_add_breakpoint(child, bp_malloc);
_add_breakpoint(child, bp_calloc);
_add_breakpoint(child, bp_free);
_add_breakpoint(child, bp_realloc);
_add_breakpoint(child, bp_reallocarray);
}

Expand Down
4 changes: 2 additions & 2 deletions src/handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void _pre_realloc(int _type, uint64_t iptr, uint64_t nmemb, uint64_t isize) {
if (_type == 1) REALLOC_COUNT++; else if (_type == 2) REALLOCARRAY_COUNT++;
uint64_t oid = get_oid();

orig_chunk = find_chunk(ptr);
orig_chunk = alloc_chunk(ptr);

log_heap("... " SYM ": %s(", oid, _name);
if (orig_chunk && orig_chunk->ops[STATE_MALLOC]) {
Expand Down Expand Up @@ -248,7 +248,7 @@ static inline void _post_realloc(int _type, uint64_t new_ptr) {
if (ptr == new_ptr) {
// the chunk shrank

ASSERT_NICE(orig_chunk == new_chunk, "the new/old Chunk meta are not equiv (new=" PTR_ERR ", old=" PTR_ERR ")", PTR_ARG(new_chunk), PTR_ARG(orig_chunk));
//ASSERT_NICE(orig_chunk == new_chunk, "the new/old Chunk meta are not equiv (new=" PTR_ERR ", old=" PTR_ERR ")", PTR_ARG(new_chunk), PTR_ARG(orig_chunk));

if (new_chunk) {
new_chunk->ops[STATE_MALLOC] = oid; // NOTE: we treat it as a malloc for now
Expand Down
12 changes: 6 additions & 6 deletions src/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ int lookup_symbols(char *fname, SymbolEntry **ses, char **interp_name) {
int sesi = 0;
while (ses[sesi]) {
SymbolEntry *cse = ses[sesi++];
if (((!cse->offset && rela_offsets[ji]) || cse->type == SE_TYPE_UNRESOLVED) && strncmp(cse->name, name, n) == 0) {
//printf("rela dyn plt: st_name: %s @ 0x%x (%d) rela idx %d\n", name, rela_offsets[ji], sym.st_shndx, ji);
if (((!cse->offset && rela_offsets[ji]) || cse->type == SE_TYPE_UNRESOLVED) && strcmp(cse->name, name) == 0) {
debug("rela dyn plt: st_name: %s @ 0x%x (%d) rela idx %d\n", name, rela_offsets[ji], sym.st_shndx, ji);
cse->type = SE_TYPE_DYNAMIC;
cse->offset = (uint64_t)rela_offsets[ji];
cse->section = sym.st_shndx;
Expand Down Expand Up @@ -225,8 +225,8 @@ int lookup_symbols(char *fname, SymbolEntry **ses, char **interp_name) {
int sesi = 0;
while (ses[sesi]) {
SymbolEntry *cse = ses[sesi++];
if (((!cse->offset && rela_offsets[ji]) || cse->type == SE_TYPE_UNRESOLVED) && strncmp(cse->name, name, n) == 0) {
//printf("dyn plt: st_name: %s @ 0x%x (%d) rela idx %d\n", name, rela_offsets[ji], sym.st_shndx, ji);
if (((!cse->offset && rela_offsets[ji]) || cse->type == SE_TYPE_UNRESOLVED) && strcmp(cse->name, name) == 0) {
debug("dyn plt: st_name: %s @ 0x%x (%d) rela idx %d\n", name, rela_offsets[ji], sym.st_shndx, ji);
cse->type = SE_TYPE_DYNAMIC_PLT;
cse->offset = (uint64_t)rela_offsets[ji];
cse->section = sym.st_shndx;
Expand All @@ -251,8 +251,8 @@ int lookup_symbols(char *fname, SymbolEntry **ses, char **interp_name) {
int sesi = 0;
while (ses[sesi]) {
SymbolEntry *cse = ses[sesi++];
if (((!cse->offset && sym.st_value) || cse->type == SE_TYPE_UNRESOLVED) && strncmp(cse->name, name, n) == 0) {
//printf("tab: st_name: %s @ 0x%x\n", name, sym.st_value);
if (((!cse->offset && sym.st_value) || cse->type == SE_TYPE_UNRESOLVED) && strcmp(cse->name, name) == 0) {
debug("tab: st_name: %s @ 0x%x\n", name, sym.st_value);
cse->type = SE_TYPE_STATIC;
cse->offset = (uint64_t)(sym.st_value) - load_addr;
cse->section = sym.st_shndx;
Expand Down

0 comments on commit b58df01

Please # to comment.