diff options
author | Chang S. Bae <changseok.bae@gmail.com> | 2018-10-08 18:49:53 -0700 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2018-10-09 10:22:57 +0300 |
commit | 960efc3ff2c8a4ecf8b968c6e485b4addd33c92f (patch) | |
tree | e5c9cd109ef8bf30e2a001a0bc53942b225813ab | |
parent | 625ea1ca4784f05bccab90a259c301d03f5149bb (diff) | |
download | nasm-960efc3ff2c8a4ecf8b968c6e485b4addd33c92f.tar.gz |
macho/reloc: Allow absolute relocation when forcing a symbol reference
The (fake) section for absolute symbols is not in the linked list. So,
when the section is not found from the index, now it simply points to
the special section.
Based-on-code-from: zenith432 <zenith432@users.sourceforge.net>
Signed-off-by: Chang S. Bae <changseok.bae@gmail.com>
-rw-r--r-- | output/outmacho.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/output/outmacho.c b/output/outmacho.c index 784ad0fe..b7bf9813 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -514,7 +514,6 @@ static int64_t add_reloc(struct section *sect, int32_t section, if (section == NO_SEG) { /* absolute (can this even happen?) */ r->ext = 0; - r->snum = NO_SECT; } else if (fi == NO_SECT) { /* external */ r->snum = raa_read(extsyms, section); @@ -593,9 +592,13 @@ static int64_t add_reloc(struct section *sect, int32_t section, break; } - /* For 64-bit Mach-O, force a symbol reference if at all possible */ - if (!r->ext && r->snum != NO_SECT && fmt.forcesym) { - struct symbol *sym = macho_find_sym(s, offset, false, false); + /* + * For 64-bit Mach-O, force a symbol reference if at all possible + * Allow for r->snum == R_ABS by searching absolute_sect + */ + if (!r->ext && fmt.forcesym) { + struct symbol *sym = macho_find_sym(s ? s : &absolute_sect, + offset, false, false); if (sym) { adjust = bytes - sym->symv[0].key; r->snum = sym->initial_snum; |