-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
macaw-base: Resolve RISC-V relocations
This builds on top of the work in GaloisInc/elf-edit#45. For now, I only add support for a select few relocation types, leaving the rest as future work. This paves a way for an eventual fix for #414.
- Loading branch information
1 parent
1a2b928
commit 93b588a
Showing
9 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule elf-edit
updated
15 files
+1 −0 | elf-edit.cabal | |
+1 −1 | src/Data/ElfEdit.hs | |
+5 −5 | src/Data/ElfEdit/HighLevel/GOT.hs | |
+6 −18 | src/Data/ElfEdit/HighLevel/Get.hs | |
+6 −16 | src/Data/ElfEdit/HighLevel/Layout.hs | |
+1 −7 | src/Data/ElfEdit/HighLevel/Types.hs | |
+3 −0 | src/Data/ElfEdit/Prim.hs | |
+3 −3 | src/Data/ElfEdit/Relocations/PPC32.hs | |
+3 −3 | src/Data/ElfEdit/Relocations/PPC64.hs | |
+444 −0 | src/Data/ElfEdit/Relocations/RISCV.hs | |
+7 −1 | tests/Makefile | |
+34 −0 | tests/Test.hs | |
+3 −0 | tests/riscv-relocs.c | |
+ − | tests/riscv32-relocs.elf | |
+ − | tests/riscv64-relocs.elf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# These binaries were obtained from https://musl.cc/ | ||
CC64=riscv64-linux-musl-gcc | ||
CC32=riscv32-linux-musl-gcc | ||
CFLAGS=-nostdlib -no-pie -static -fno-stack-protector | ||
CFLAGS_DYNAMIC=-nostartfiles -fno-stack-protector | ||
|
||
rv32gc = $(patsubst %.c,%-rv32gc.exe,$(wildcard *.c)) | ||
rv64gc = $(patsubst %.c,%-rv64gc.exe,$(wildcard *.c)) | ||
|
||
all: $(rv32gc) $(rv64gc) | ||
|
||
%-rv32gc.exe : %.c | ||
$(CC32) $(CFLAGS) -O0 $< -o $@ | ||
|
||
%-rv64gc.exe : %.c | ||
$(CC32) $(CFLAGS) -O0 $< -o $@ | ||
|
||
# This test relies on the binary having dynamic relocations. | ||
relocs-rv32gc.exe: relocs.c | ||
$(CC32) $(CFLAGS_DYNAMIC) $< -o $@ | ||
|
||
relocs-rv64gc.exe: relocs.c | ||
$(CC64) $(CFLAGS_DYNAMIC) $< -o $@ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
R { fileEntryPoint = Nothing | ||
, funcs = [(0x1e0, [(0x1e0,26),(0x1fa,12)])] | ||
, ignoreBlocks = [0x1d0] | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
R { fileEntryPoint = Nothing | ||
, funcs = [(0x2c0, [(0x2c0,28),(0x2dc,12)])] | ||
, ignoreBlocks = [0x2b0] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <stdio.h> | ||
|
||
int main(void) { | ||
printf("Hello, %s!\n", "World"); | ||
return 0; | ||
} |