-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'lsda_sym_minus_sym' into 'main'
Check on both symbols in symbol_minus_symbol for END symbols Closes #599 and debloating/dykondo#128 See merge request rewriting/ddisasm!1229
- Loading branch information
Showing
7 changed files
with
112 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CXX="g++" | ||
EXEC= | ||
|
||
all: ex_original.s | ||
# NOTE: `-T linker-script.ld` | ||
# This is to place .gcc_except_table *before* .note.gnu.build-id | ||
# so that the reference label for the end of the section is aligned | ||
# with the adjacent section. Otherwise, the next section can be some | ||
# discarded one, which would prevent from demonstrating the issue. | ||
# | ||
$(CXX) -T linker-script.ld -o ex ex_original.s | ||
@ $(EXEC) ./ex > out.txt | ||
clean: | ||
rm -f ex out.txt | ||
rm -fr ex.unstripped *.old* dl_files *.gtirb | ||
check: | ||
@ $(EXEC) ./ex >/tmp/res.txt | ||
@ diff out.txt /tmp/res.txt && echo TEST OK |
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,67 @@ | ||
.section .text | ||
|
||
#----------------------------------- | ||
.type foo, @function | ||
foo: | ||
|
||
.cfi_startproc | ||
.cfi_lsda 27, .L_call_site_start | ||
endbr64 | ||
pushq %rbp | ||
movq %rsp,%rbp | ||
nop | ||
popq %rbp | ||
retq | ||
.cfi_endproc | ||
|
||
# Entry point | ||
.globl main | ||
.type main, @function | ||
main: | ||
call callThrower # Call a function that may "throw" an exception | ||
mov $60, %rax # syscall: exit | ||
xor %rdi, %rdi # status: 0 | ||
syscall | ||
|
||
# Dummy function simulating an exception thrower | ||
.type callThrower, @function | ||
callThrower: | ||
ret # Simply return (replace with an actual throw in C++) | ||
|
||
# Exception Handling Table | ||
.section .gcc_except_table, "a", @progbits | ||
.align 4 | ||
|
||
.L_entry_start: | ||
.byte 0x1 # Entry indicating an exception | ||
.byte 0x0 | ||
.byte 0x0 | ||
.byte 0x7d | ||
.byte 0x0 | ||
.byte 0x0 | ||
.byte 0x0 | ||
.byte 0x0 | ||
.byte 0x0 | ||
.byte 0x0 | ||
.byte 0x0 | ||
.byte 0x0 | ||
.byte 0x0 | ||
.byte 0x0 | ||
.byte 0x0 | ||
.byte 0x0 | ||
|
||
.L_call_site_start: | ||
.byte 0xff # Start of a call site | ||
.byte 0xff # Additional indicator byte | ||
.byte 0x1 # Additional indicator byte | ||
# | ||
# With this example, if a boundary_sym_expr is not correctly created | ||
# for symbol_minus_symbol (either the first or the second symbol, or | ||
# both) or an END symbol is not chosen for such a symbol, | ||
# the assembler will fail with an error, such as | ||
# | ||
# "Error: invalid operands (.note.gnu.property and .gcc_except_table | ||
# sections) for '-'" | ||
# | ||
.uleb128 .L_end - .L_end # Zero-length entry at the very end of the table | ||
.L_end: |
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 @@ | ||
SECTIONS { | ||
.gcc_except_table : { *(.gcc_except_table) } | ||
} | ||
INSERT BEFORE .note.gnu.build-id; |
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
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