Skip to content

Commit

Permalink
elf: Add test Elf_Ehdr.readelf
Browse files Browse the repository at this point in the history
$ ./src/tests/ulpatch_test -f Elf_Ehdr.readelf -v
=========================================
===
=== ULPatch Testing
===
===  version: v0.5.7-78-g0408-dirty
=== ---------------------------
===   13/74   Elf_Ehdr.readelf
ELF Header:
 Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
 Class:                             ELF64
 Data:                              2's complement, little endian
 Version:                           1 (current)
 OS/ABI:                            UNIX - System V
 ABI Version:                       0
 Type:                              Executable file
 Machine:                           x86_64
 Version:                           0x1
 Entry point address:               0x4060b0
 Start of program headers:          64 (bytes into file)
 Start of section headers:          7122000 (bytes into file)
 Flags:                             0x0
 Size of this header:               64 (bytes)
 Size of program headers:           56 (bytes)
 Number of program headers:         13
 Size of section headers:           64 (bytes)
 Number of section headers:         43
 Section header string table index: 42
4677us OK

Signed-off-by: Rong Tao <[email protected]>
  • Loading branch information
Rtoax committed Jul 29, 2024
1 parent 04086f0 commit f9b50d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/tests/elf/ehdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ TEST(Elf_Ehdr, print, 0)
print_ehdr(NULL, &ehdr1);
return 0;
}

TEST(Elf_Ehdr, readelf, 0)
{
struct elf_file *elf;
elf = elf_file_open(ulpatch_test_path);
if (!elf) {
lerror("open %s failed.\n", ulpatch_test_path);
return -ENOENT;
}

print_ehdr(stdout, elf->ehdr);

elf_file_close(ulpatch_test_path);
return 0;
}
4 changes: 2 additions & 2 deletions src/tests/elf/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ TEST(Elf, open_close, 0)
{
int i;
int ret = 0;
struct elf_file *e;

for (i = 0; i < ARRAY_SIZE(test_elfs); i++) {
if (!fexist(test_elfs[i]))
continue;

struct elf_file __unused *e = elf_file_open(test_elfs[i]);

e = elf_file_open(test_elfs[i]);
if (!e) {
lerror("open %s failed.\n", test_elfs[i]);
ret = -1;
Expand Down

0 comments on commit f9b50d4

Please sign in to comment.