Skip to content

Commit 69b4a07

Browse files
committed
Fixed the function info function address (removed the image begin address)
1 parent f086f18 commit 69b4a07

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

include/functionInfo/functionInfo.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ extern "C" {
3030
#include <stddef.h>
3131
#include <stdint.h>
3232

33-
// The actual function address is beginOffset + imageBegin.
3433
struct functionInfo {
35-
uintptr_t beginOffset,
36-
imageBegin;
34+
uintptr_t begin;
3735
size_t length;
3836
bool found;
3937
};

src/parser/file/binaryFile.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ bool binaryFile_getFunctionInfo(struct binaryFile* self, const char* functionNam
6161
result = elfFile_getFunctionInfo(self->concrete, functionName, info);
6262
#endif
6363

64-
if (result) {
65-
info->imageBegin = (uintptr_t) self->startAddress;
66-
}
6764
return result;
6865
}
6966

src/parser/file/elf/elfFile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ bool elfFile_getFunctionInfo(struct elfFile* self, const char* functionName, str
372372

373373
vector_iterate(struct function, &self->functions, {
374374
if (strcmp(element->linkedName, functionName) == 0) {
375-
info->begin = (uintptr_t) element->startAddress;
375+
info->begin = (uintptr_t) element->startAddress + self->_.relocationOffset;
376376
info->length = element->length;
377377
return true;
378378
}

src/parser/file/macho/machoFile.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ bool machoFile_getFunctionInfo(struct machoFile* self, const char* functionName,
383383

384384
vector_iterate(pair_funcFile_t, &self->functions, {
385385
if (strcmp(element->first.linkedName, functionName) == 0) {
386-
info->beginOffset = (uintptr_t) element->first.startAddress;
386+
info->begin = (uintptr_t) element->first.startAddress + (uintptr_t) self->_.startAddress
387+
- (self->_.inMemory ? self->text_vmaddr : self->addressOffset);
387388
info->length = element->first.length;
388389
return true;
389390
}

0 commit comments

Comments
 (0)