Commit bee2a11e authored by Marc Herbert's avatar Marc Herbert Committed by Chris Lamb

Add new elfmix.a ELF test file with a range of different file types.

Now that StaticLibFile is out of the way, show off ArFile's recursive
ability to:

- not care about the .a suffix and not behave differently depending on
  filenames;
- not crash and lose everything when some archive members are not ELF;
- gracefully fall back and run the next best tool for a cross-compiled
  ELF and a sample of non-ELF members - including the corresponding .c
  source.

Tests issue #64, see more details there.

In addition to the .c source file, the regen_elfmix.sh script that generated
the .a files is embedded in the .a files themselves if ever needed. For
size considerations no cross-compiler is provided.
Signed-off-by: Chris Lamb's avatarChris Lamb <lamby@debian.org>

Gbp-Dch: ignore
parent ce6c03fe
Pipeline #70588 passed with stage
in 15 minutes and 5 seconds
......@@ -145,6 +145,49 @@ def test_lib_compare_non_existing(monkeypatch, lib1):
assert len(difference.details) > 0
TEST_LIBMIX1_PATH = data('elfmix1.not_a')
TEST_LIBMIX2_PATH = data('elfmix2.a')
@pytest.fixture
def libmix1():
return specialize(FilesystemFile(TEST_LIBMIX1_PATH))
@pytest.fixture
def libmix2():
return specialize(FilesystemFile(TEST_LIBMIX2_PATH))
@pytest.fixture
def libmix_differences(libmix1, libmix2):
return libmix1.compare(libmix2).details
@skip_unless_tools_exist('readelf', 'objdump')
@skip_if_tool_version_is('readelf', readelf_version, '2.29')
@skip_if_binutils_does_not_support_x86()
def test_libmix_differences(libmix_differences):
assert len(libmix_differences) == 5
file_list, mach_o, x86_o, src_c, x_obj = libmix_differences
# Check order and basic identification
assert file_list.source1 == 'file list'
assert "Falling back to binary" in mach_o.comments[0]
x86_o = x86_o.details[0]
assert x86_o.source1.startswith('objdump ')
assert src_c.source1.endswith('.c')
x_obj = x_obj.details[0]
assert x_obj.source1.startswith('readelf ')
# Content
assert 'return42_or_3' in file_list.unified_diff
assert mach_o.unified_diff == get_data('elfmix_mach_o_expected_diff')
assert x86_o.unified_diff == get_data('elfmix_disassembly_expected_diff')
assert src_c.unified_diff == get_data('elfmix_src_c_expected_diff')
assert x_obj.unified_diff == get_data('elfmix_x_obj_expected_diff')
TEST_DBGSYM_DEB1_PATH = data('dbgsym/add/test-dbgsym_1_amd64.deb')
TEST_DBGSYM_DEB2_PATH = data('dbgsym/mult/test-dbgsym_1_amd64.deb')
......
@@ -3,10 +3,10 @@
Disassembly of section .text:
0000000000000000 <return42_or_3>:
return42_or_3():
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
- 4: b8 2a 00 00 00 mov $0x2a,%eax
+ 4: b8 2b 00 00 00 mov $0x2b,%eax
9: 5d pop %rbp
a: c3 retq
@@ -23,15 +23,15 @@
00000160: 0100 0000 000e 0a00 000e 0a00 0000 0000 ................
00000170: 0200 0000 1800 0000 5002 0000 0100 0000 ........P.......
00000180: 6002 0000 1000 0000 0b00 0000 5000 0000 `...........P...
00000190: 0000 0000 0000 0000 0000 0000 0100 0000 ................
000001a0: 0100 0000 0000 0000 0000 0000 0000 0000 ................
000001b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000001c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-000001d0: 0000 0000 0000 0000 5548 89e5 b82a 0000 ........UH...*..
+000001d0: 0000 0000 0000 0000 5548 89e5 b82b 0000 ........UH...+..
000001e0: 005d c300 0000 0000 0000 0000 0000 0000 .]..............
000001f0: 0b00 0000 0000 0001 0000 0000 0000 0000 ................
00000200: 0000 0000 0000 0000 1400 0000 0000 0000 ................
00000210: 017a 5200 0178 1001 100c 0708 9001 0000 .zR..x..........
00000220: 2400 0000 1c00 0000 b0ff ffff ffff ffff $...............
00000230: 0b00 0000 0000 0000 0041 0e10 8602 430d .........A....C.
00000240: 0600 0000 0000 0000 0000 0000 0100 0006 ................
@@ -1,5 +1,5 @@
int return42_or_3()
{
- return 42; // for sed
+ return 43; // for sed
}
@@ -1,4 +1,4 @@
Hex dump of section '.text':
- 0x00000000 3641007d 012ca21d f0 6A.}.,...
+ 0x00000000 3641007d 012cb21d f0 6A.}.,...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment