summaryrefslogtreecommitdiff
path: root/output/outmac64.c
diff options
context:
space:
mode:
Diffstat (limited to 'output/outmac64.c')
-rw-r--r--output/outmac64.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/output/outmac64.c b/output/outmac64.c
index f633db0..358ae6e 100644
--- a/output/outmac64.c
+++ b/output/outmac64.c
@@ -299,19 +299,20 @@ static uint8_t get_section_fileindex_by_index(const int32_t index)
static struct symbol *get_closest_section_symbol_by_offset(uint8_t fileindex, int64_t offset)
{
- struct symbol *sym;
+ struct symbol *nearest = NULL;
+ struct symbol *sym;
- for (sym = syms; sym != NULL; sym = sym->next) {
- if ((sym->sect != NO_SECT) &&
- (sym->sect == fileindex) &&
- ((int64_t)sym->value >= offset))
- return sym;
- }
+ for (sym = syms; sym; sym = sym->next) {
+ if ((sym->sect != NO_SECT) && (sym->sect == fileindex)) {
+ if ((int64_t)sym->value > offset)
+ break;
+ nearest = sym;
+ }
+ }
- return NULL;
+ return nearest;
}
-
/*
* Special section numbers which are used to define Mach-O special
* symbols, which can be used with WRT to provide PIC relocation
@@ -579,7 +580,7 @@ static void macho_output(int32_t secto, const void *data,
case OUT_REL4ADR:
p = mydata;
- WRITELONG(p, *(int64_t *)data);
+ WRITELONG(p, *(int64_t *)data + 4 - size);
if (section == secto)
nasm_error(ERR_PANIC, "intra-section OUT_REL4ADR");