From: nasm-bot f. H. P. A. <hp...@zy...> - 2016-02-16 08:33:19
|
Commit-ID: 4e5fbcb81bc9ee65d2b6aa826e1a26c94701e1e9 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=4e5fbcb81bc9ee65d2b6aa826e1a26c94701e1e9 Author: H. Peter Anvin <hp...@zy...> AuthorDate: Tue, 16 Feb 2016 00:29:48 -0800 Committer: H. Peter Anvin <hp...@zy...> CommitDate: Tue, 16 Feb 2016 00:29:48 -0800 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 <hp...@zy...> --- output/outmacho.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/output/outmacho.c b/output/outmacho.c index 378fe6d..98e1a42 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 */ |