summaryrefslogtreecommitdiff
path: root/output/outelf64.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-06-25 17:30:58 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-06-25 17:30:58 -0700
commitca2a788edfa310f758a7706e284361fcba10ebea (patch)
tree2596176854c1a9d871cb1021b62a3572fec25247 /output/outelf64.c
parent559d936ad7de8330965f9b7456fe3cb48d49a386 (diff)
downloadnasm-ca2a788edfa310f758a7706e284361fcba10ebea.tar.gz
ELF: remove loop invariant calculation of global offset
The global symbol offset is a loop invariant; no need to compute it over and over. The compiler probably will not be able to do this for us due to global variables and function calls. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'output/outelf64.c')
-rw-r--r--output/outelf64.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/output/outelf64.c b/output/outelf64.c
index 44ff8e06..05a53566 100644
--- a/output/outelf64.c
+++ b/output/outelf64.c
@@ -1363,6 +1363,7 @@ static struct SAA *elf_build_reltab(uint64_t *len, struct Reloc *r)
{
struct SAA *s;
uint8_t *p, entry[24];
+ int32_t global_offset;
if (!r)
return NULL;
@@ -1370,15 +1371,18 @@ static struct SAA *elf_build_reltab(uint64_t *len, struct Reloc *r)
s = saa_init(1L);
*len = 0;
+ /*
+ * How to onvert from a global placeholder to a real symbol index;
+ * the +2 refers to the two special entries, the null entry and
+ * the filename entry.
+ */
+ global_offset = -GLOBAL_TEMP_BASE + nsects + nlocals + ndebugs + 2;
+
while (r) {
int32_t sym = r->symbol;
- /*
- * Create a real symbol index; the +2 refers to the two special
- * entries, the null entry and the filename entry.
- */
if (sym >= GLOBAL_TEMP_BASE)
- sym += -GLOBAL_TEMP_BASE + nsects + nlocals + ndebugs + 2;
+ sym += global_offset;
p = entry;
WRITEDLONG(p, r->address);