summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-02-20 14:47:29 -0500
committermidipix <writeonce@midipix.org>2019-02-20 23:31:15 -0500
commit54e94f38f5e4d9e4ad51766ea5ca97ec8839114c (patch)
tree684fdb3cc0c7549990602db228482ccea8ba913e
parent9e15f6c411ab058dc38d416a0871747a4d208b82 (diff)
downloadmdso-54e94f38f5e4d9e4ad51766ea5ca97ec8839114c.tar.bz2
mdso-54e94f38f5e4d9e4ad51766ea5ca97ec8839114c.tar.xz
ABI & specs: symbol reference optimization: use image-relative relocations.
-rw-r--r--include/mdso/mdso_specs.h13
-rw-r--r--src/logic/mdso_asmgen_symentry.c12
-rw-r--r--src/object/mdso_objgen_symentry.c4
3 files changed, 18 insertions, 11 deletions
diff --git a/include/mdso/mdso_specs.h b/include/mdso/mdso_specs.h
index f8dc9cc..63bc9f4 100644
--- a/include/mdso/mdso_specs.h
+++ b/include/mdso/mdso_specs.h
@@ -33,14 +33,19 @@ struct mdso_def_entry {
char * string;
};
+struct mdso_got_entry {
+ void * addr;
+ uintptr_t rsymstr;
+};
+
struct mdso_sym_entry {
- char * string;
- struct mdso_meta_record * meta;
+ uintptr_t rsymstr;
+ uintptr_t rmeta;
};
struct mdso_ref_entry {
- uintptr_t * backref;
- uintptr_t * symref;
+ uintptr_t rbackref;
+ uintptr_t rsymref;
};
struct mdso_meta_record {
diff --git a/src/logic/mdso_asmgen_symentry.c b/src/logic/mdso_asmgen_symentry.c
index cba360d..ef38182 100644
--- a/src/logic/mdso_asmgen_symentry.c
+++ b/src/logic/mdso_asmgen_symentry.c
@@ -28,7 +28,7 @@ int mdso_asmgen_symentry(
{
const char * const * line;
const char * alignstr;
- const char * ptrsize;
+ const char * rvapad;
const char * uscore;
if (mdso_dprintf(fdout,"\t.file \".%s_symentry.s\"\n",sym) < 0)
@@ -36,11 +36,11 @@ int mdso_asmgen_symentry(
if (dctx->cctx->drvflags & MDSO_DRIVER_QUAD_PTR) {
alignstr = "\t.balign 16\n\n";
- ptrsize = ".quad";
+ rvapad = "\t.long 0\n";
uscore = "";
} else {
alignstr = "\t.balign 8\n\n";
- ptrsize = ".long";
+ rvapad = "";
uscore = "_";
}
@@ -57,10 +57,12 @@ int mdso_asmgen_symentry(
if ((mdso_dprintf(fdout,"__imp_%s%s:\n",uscore,sym)) < 0)
return MDSO_FILE_ERROR(dctx);
- if ((mdso_dprintf(fdout,"\t%s\t.symstr_%s\n",ptrsize,sym)) < 0)
+ if ((mdso_dprintf(fdout,"\t.rva\t.symstr_%s\n%s",
+ sym,rvapad)) < 0)
return MDSO_FILE_ERROR(dctx);
- if ((mdso_dprintf(fdout,"\t%s\t.dsometa_%s\n",ptrsize,dctx->cctx->libname)) < 0)
+ if ((mdso_dprintf(fdout,"\t.rva\t.dsometa_%s\n%s",
+ dctx->cctx->libname,rvapad)) < 0)
return MDSO_FILE_ERROR(dctx);
if ((mdso_dprintf(fdout,"\t.linkonce discard\n")) < 0)
diff --git a/src/object/mdso_objgen_symentry.c b/src/object/mdso_objgen_symentry.c
index 429b641..159f924 100644
--- a/src/object/mdso_objgen_symentry.c
+++ b/src/object/mdso_objgen_symentry.c
@@ -115,12 +115,12 @@ int mdso_objgen_symentry(
if (dctx->cctx->drvflags & MDSO_DRIVER_QUAD_PTR) {
aattr = PE_IMAGE_SCN_ALIGN_16BYTES;
machine = PE_IMAGE_FILE_MACHINE_AMD64;
- reltype = PE_IMAGE_REL_AMD64_ADDR64;
+ reltype = PE_IMAGE_REL_AMD64_ADDR32NB;
relrva = 8;
} else {
aattr = PE_IMAGE_SCN_ALIGN_4BYTES;
machine = PE_IMAGE_FILE_MACHINE_I386;
- reltype = PE_IMAGE_REL_I386_DIR32;
+ reltype = PE_IMAGE_REL_I386_DIR32NB;
relrva = 4;
}