aboutsummaryrefslogtreecommitdiffhomepage
path: root/obj/obj.h
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-14 12:15:59 +0100
committerlemon <lsof@mailbox.org>2025-12-14 12:15:59 +0100
commitd8b4e87af669c2b260686a5db67f7f02b4c164d9 (patch)
treec46f03cc43462953dfb82df935bb7e2adcb098e4 /obj/obj.h
parent59ca5a8db396e3e9c395793d49e1cab05d2d3261 (diff)
various relocation related optimization
With 59ca5a8db, querying if a symbol is defined is cheap. If we're compiling code that calls foo() and we defined foo() in this compilation unit, we already know its offset within the .text section, so use it instead of emitting a relocation for the linker to handle. Also, put small literal data in the .text section instead of .rodata. This seems to improve performance (cache locality?), and as a bonus, it will be good for aarch64's instr encoding with smallish PC-relative offsets.
Diffstat (limited to 'obj/obj.h')
-rw-r--r--obj/obj.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/obj/obj.h b/obj/obj.h
index 8e9dea8..59769ff 100644
--- a/obj/obj.h
+++ b/obj/obj.h
@@ -23,7 +23,7 @@ enum section { Snone, Stext, Srodata, Sdata, Sbss };
void objini(const char *infile, const char *outfile);
void objdeffunc(const char *nam, bool globl, uint off, uint siz);
-enum section objhassym(const char *name);
+enum section objhassym(const char *name, uint *off);
uint objnewdat(const char *name, enum section, bool globl, uint siz, uint align);
void objreloc(const char *sym, enum relockind, enum section, uint off, vlong addend);
void objfini(void);