From 41e7d89e2fb94865fbef5e0c16152d1becec5ace Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Thu, 19 Aug 2021 21:07:45 -0700 Subject: [PATCH] Expand todo descriptions and add -fPIE to executable --- linker/src/lib.rs | 14 ++++++++++++++ linker/tests/Makefile | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/linker/src/lib.rs b/linker/src/lib.rs index 40757fb96c..2321738773 100644 --- a/linker/src/lib.rs +++ b/linker/src/lib.rs @@ -45,10 +45,24 @@ pub fn preprocess(matches: &ArgMatches) -> io::Result { })?; // TODO: Extract PLT related information for these functions. + // The information need is really the address of each plt version of each application function. + // To find this, first get the dynmaic symbols for the app functions. + // Then reference them on the dynamic relocation table to figure out their plt function number. + // Then with the plt base address and that function number(or scanning the code), it should be possible to find the address. + // TODO: For all text sections check for function calls to app functions. + // This should just be disassembly and then scanning for jmp and call style ops that jump to the plt offsets we care about. + // The data well be store in a list for each function name. + // Not really sure if/how namespacing will lead to conflicts (i.e. naming an app function printf when c alread has printf). + // TODO: Store all this data in a nice format. + // TODO: Potentially create a version of the executable with certain dynamic and PLT information deleted. + // Remove shared library dependencies. + // Delete extra plt entries, dynamic symbols, and dynamic relocations (might require updating other plt entries, may not worth it). + // Add regular symbols pointing to 0 for the app functions (maybe not needed if it is just link metadata). // It may be fine to just add some of this information to the metadata instead and deal with it on final exec creation. + // If we are copying the exec to a new location in the background anyway it may be basically free. Ok(0) } diff --git a/linker/tests/Makefile b/linker/tests/Makefile index 3034951821..8b153ed8df 100644 --- a/linker/tests/Makefile +++ b/linker/tests/Makefile @@ -1,7 +1,7 @@ all: platform platform: platform.c libapp.so - $(CC) -O2 -fPIC -o $@ $^ + $(CC) -O2 -fPIC -fPIE -o $@ $^ libapp.so: app.c $(CC) -O2 -fPIC -shared -o $@ $^