From cac9c3a4d13211064e2f8edb5e70813b915324d3 Mon Sep 17 00:00:00 2001 From: Daniel Matichuk Date: Mon, 17 Jul 2023 17:00:28 -0700 Subject: [PATCH 1/2] macaw-aarch32: add test for binary containing empty section --- macaw-aarch32/tests/arm/Makefile | 4 ++++ .../tests/arm/test-empty-section-a32.exe | Bin 0 -> 1256 bytes .../arm/test-empty-section-a32.mcw.expected | 5 +++++ macaw-aarch32/tests/arm/test-empty-section.c | 20 ++++++++++++++++++ 4 files changed, 29 insertions(+) create mode 100755 macaw-aarch32/tests/arm/test-empty-section-a32.exe create mode 100644 macaw-aarch32/tests/arm/test-empty-section-a32.mcw.expected create mode 100644 macaw-aarch32/tests/arm/test-empty-section.c diff --git a/macaw-aarch32/tests/arm/Makefile b/macaw-aarch32/tests/arm/Makefile index 1848c373..cd813b9f 100644 --- a/macaw-aarch32/tests/arm/Makefile +++ b/macaw-aarch32/tests/arm/Makefile @@ -28,6 +28,10 @@ all: $(patsubst %.c,%-a32.exe,$(wildcard *.c)) $(patsubst %.c,%-t32.exe,$(wildca %-mixed.s: %-mixed.c $(A32CC) -fno-stack-protector -S -c $< -o $@ +# doesn't work with arm-none-eabi +test-empty-section-a32.exe: test-empty-section.c + arm-linux-gnueabi-gcc -nostartfiles -O2 -static $< -o $@ + syscall.o: syscall.s $(A32AS) $< -o $@ diff --git a/macaw-aarch32/tests/arm/test-empty-section-a32.exe b/macaw-aarch32/tests/arm/test-empty-section-a32.exe new file mode 100755 index 0000000000000000000000000000000000000000..a0dce4b1e0944ce276f758711960f2fa059c12ea GIT binary patch literal 1256 zcma)5Jx>%-6uobDSC&Yz5adG*Zm|VlGY+~&F`9s=#KcdO!dR>`%mmlCvt;LO0*#Vb z+S|Iltu38}jXkX)BoHfq0iH864<~5hP0l;-+)`DI z8cRxbsY(&CekmvMG@qGD20%n9ajGO($9szZ>apb>68vu07XH)ZE)kuH)97xvA7I zi&I$J3q8Ln>H@l@E6?Oqp{)AVP;pqDQKN-1HLlKD6BdI1GVYsJ$e8Dy>U0F_Ni}!* z#|p{r^SYFcOnpW9bu@zR!Liqpap>~#9b3YoYcl_3wdMZ!ObL!TI%GKRSleN1LvPt}xTc%! z$XSz`C$&H}rP1)?xDjiwqZ^G(g;8+aPa@Ltno%+jGCKj%vXn6Jv?o*|PQ2C9o)6ZY zlwX-%)YhT19(5hR+k6w)%|IL-ZfbF`wm56;Rx6C47FQlPp4OeF-$l*X#(WcC4k z6?{AVKRhpE#jN9i`I7ioc*eV6{$pb%k3QZnUsw81Q*H7Xqs;@H&!vFzpU + +uint64_t x = 0; + +int __attribute__((noinline)) test_strd() { + x = 42; + return x == 42; +} + +int main() { + test_strd(); + return 0; +} \ No newline at end of file From b0fbe5034b454352549fcd1dfe8bb985e74c01c4 Mon Sep 17 00:00:00 2001 From: Daniel Matichuk Date: Tue, 18 Jul 2023 13:16:18 -0700 Subject: [PATCH 2/2] Data.Macaw.Memory.ElfLoader: fix overlapping section and program header error This error is caused by a bug in the IntervalMap implementation prior to 0.6.2, which had inconsistent semantics for empty intervals (see: https://github.com/bokesan/IntervalMap/issues/9) fixes #302 --- base/macaw-base.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/macaw-base.cabal b/base/macaw-base.cabal index 6025317d..06554f67 100644 --- a/base/macaw-base.cabal +++ b/base/macaw-base.cabal @@ -38,7 +38,7 @@ library exceptions, filepath, galois-dwarf >= 0.2.2, - IntervalMap >= 0.5, + IntervalMap >= 0.6.2.0, lens >= 4.7, mtl, panic,