diff options
author | H. Peter Anvin <hpa@zytor.com> | 2016-02-16 00:29:48 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2016-02-16 00:29:48 -0800 |
commit | 4e5fbcb81bc9ee65d2b6aa826e1a26c94701e1e9 (patch) | |
tree | 9cf412b06691c90b43a853f5ec40dec664b4f0c3 | |
parent | c44bfaa05485556c025fe10ccd04a80ee61a93dd (diff) | |
download | nasm-4e5fbcb81bc9ee65d2b6aa826e1a26c94701e1e9.tar.gz |
outmacho: use section table lookup for local symbol references
When generating local symbol references, don't loop over all the
sections like we used to...
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | output/outmacho.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/output/outmacho.c b/output/outmacho.c index 378fe6d7..98e1a421 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -425,7 +425,7 @@ static void add_reloc(struct section *sect, int32_t section, /* intra-section */ r->type = 1; // X86_64_RELOC_SIGNED } else { - /* inter-section */ + /* inter-section */ r->type = 1; // X86_64_RELOC_SIGNED fi = get_section_fileindex_by_index(section); @@ -1145,14 +1145,9 @@ static void macho_write_section (void) offset which we already have. The linker takes care of the rest of the address. */ if (!r->ext) { - /* generate final address by section address and offset */ - for (s2 = sects, fi = 1; - s2 != NULL; s2 = s2->next, fi++) { - if (fi == r->snum) { - l += s2->addr; - break; - } - } + /* generate final address by section address and offset */ + nasm_assert(r->snum <= seg_nsects); + l += sectstab[r->snum]->addr; } /* write new offset back */ |