-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds ability to read the debug link info out of ELF files, this is an alternative mechanism to the debug id to locate debug files.
- Loading branch information
Showing
11 changed files
with
264 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
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
1 change: 1 addition & 0 deletions
1
symbolic-testutils/fixtures/linux/elf_debuglink/gen/debug_info.txt.crc
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 @@ | ||
abf39bdc |
Binary file added
BIN
+15.6 KB
symbolic-testutils/fixtures/linux/elf_debuglink/gen/elf_with123_debuglink
Binary file not shown.
Binary file added
BIN
+15.6 KB
symbolic-testutils/fixtures/linux/elf_debuglink/gen/elf_with12_debuglink
Binary file not shown.
Binary file added
BIN
+15.6 KB
symbolic-testutils/fixtures/linux/elf_debuglink/gen/elf_with1_debuglink
Binary file not shown.
Binary file added
BIN
+15.7 KB
symbolic-testutils/fixtures/linux/elf_debuglink/gen/elf_with_compressed_debuglink
Binary file not shown.
Binary file added
BIN
+15.6 KB
symbolic-testutils/fixtures/linux/elf_debuglink/gen/elf_with_debuglink
Binary file not shown.
Binary file added
BIN
+15.5 KB
symbolic-testutils/fixtures/linux/elf_debuglink/gen/elf_without_debuglink
Binary file not shown.
49 changes: 49 additions & 0 deletions
49
symbolic-testutils/fixtures/linux/elf_debuglink/generate_elf_debug_link.sh
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,49 @@ | ||
#!/bin/bash | ||
|
||
# This script was used to generate the fixtures in the "gen" directory, used to test the | ||
# `ElfObject::debug_link` method. | ||
|
||
# Pre-requisites: | ||
# | ||
# - gcc | ||
# - eu-elfcompress (elfutils) | ||
# - objcopy (GNU Binary Utilities) | ||
# - crc32 (perl-archive-zip) | ||
|
||
OUTPUT=gen | ||
|
||
# 0. Clean and remake output directory, switch to it | ||
rm -rf $OUTPUT | ||
mkdir -p $OUTPUT | ||
cd $OUTPUT | ||
|
||
# 1. compile our C example. To keep size low, let's compile the simplest program we can write. | ||
gcc -x c -Os -o elf_without_debuglink - << EOF | ||
int main() { | ||
return 0; | ||
} | ||
EOF | ||
|
||
# 2. generate some fake debug file. objcopy doesn't require the file to be a proper debug file, | ||
# only that it exists (to compute its CRC and embed it in the section). | ||
# Let's use a simple text file. | ||
echo "Fake debug info" > debug_info.txt | ||
|
||
# 3. compute the expected CRC for debug_info.txt. | ||
# This will be used in tests to check we find the correct CRC. | ||
crc32 debug_info.txt > debug_info.txt.crc | ||
|
||
# 4. Add the debug info to a copy of our binary | ||
objcopy --add-gnu-debuglink=debug_info.txt elf_{without,with}_debuglink | ||
|
||
# 5. To test for the various possible paddings, also add debug info | ||
# with different-sized filenames | ||
cp debug_info{,1}.txt && objcopy --add-gnu-debuglink=debug_info1.txt elf_{without,with1}_debuglink | ||
cp debug_info{,12}.txt && objcopy --add-gnu-debuglink=debug_info12.txt elf_{without,with12}_debuglink | ||
cp debug_info{,123}.txt && objcopy --add-gnu-debuglink=debug_info123.txt elf_{without,with123}_debuglink | ||
|
||
# 6. To test the "Owned" case, let's make a copy of the ELF with a compressed section | ||
eu-elfcompress -v --force --name ".gnu_debuglink" -t zlib -o elf_with{_compressed,}_debuglink | ||
|
||
# 7. Remove debug info files that aren't actually needed by the tests | ||
rm *.txt |