Added tests for object file tools. (".o")
This commit is contained in:
parent
f686497d55
commit
54206f3ffc
6 changed files with 81 additions and 5 deletions
BIN
golden-files/input/Mcrt1.o
Normal file
BIN
golden-files/input/Mcrt1.o
Normal file
Binary file not shown.
5
golden-files/results/objdump_disassemble-Mcrt1_o
Normal file
5
golden-files/results/objdump_disassemble-Mcrt1_o
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
./input/Mcrt1.o: file format elf32-i386
|
||||
|
||||
objdump: ./input/Mcrt1.o: not a dynamic object
|
||||
objdump: ./input/Mcrt1.o: Invalid operation
|
||||
23
golden-files/results/objdump_headers-Mcrt1_o
Normal file
23
golden-files/results/objdump_headers-Mcrt1_o
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
./input/Mcrt1.o: file format elf32-i386
|
||||
./input/Mcrt1.o
|
||||
architecture: i386, flags 0x00000000:
|
||||
|
||||
start address 0x00000000
|
||||
|
||||
Sections:
|
||||
Idx Name Size VMA LMA File off Algn
|
||||
0 .text 00000000 00000000 00000000 00000034 2**0
|
||||
CONTENTS, ALLOC, LOAD, READONLY, CODE
|
||||
1 .data 00000000 00000000 00000000 00000034 2**0
|
||||
CONTENTS, ALLOC, LOAD, DATA
|
||||
2 .bss 00000000 00000000 00000000 00000034 2**0
|
||||
ALLOC
|
||||
3 .note.GNU-stack 00000000 00000000 00000000 00000034 2**0
|
||||
CONTENTS, READONLY
|
||||
4 .gnu_debuglink 0000000c 00000000 00000000 00000034 2**0
|
||||
CONTENTS, READONLY
|
||||
SYMBOL TABLE:
|
||||
no symbols
|
||||
|
||||
|
||||
44
golden-files/results/readelf-Mcrt1_o
Normal file
44
golden-files/results/readelf-Mcrt1_o
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
ELF Header:
|
||||
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
|
||||
Class: ELF32
|
||||
Data: 2's complement, little endian
|
||||
Version: 1 (current)
|
||||
OS/ABI: UNIX - System V
|
||||
ABI Version: 0
|
||||
Type: REL (Relocatable file)
|
||||
Machine: Intel 80386
|
||||
Version: 0x1
|
||||
Entry point address: 0x0
|
||||
Start of program headers: 0 (bytes into file)
|
||||
Start of section headers: 124 (bytes into file)
|
||||
Flags: 0x0
|
||||
Size of this header: 52 (bytes)
|
||||
Size of program headers: 0 (bytes)
|
||||
Number of program headers: 0
|
||||
Size of section headers: 40 (bytes)
|
||||
Number of section headers: 7
|
||||
Section header string table index: 6
|
||||
|
||||
Section Headers:
|
||||
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
|
||||
[ 0] NULL 00000000 000000 000000 00 0 0 0
|
||||
[ 1] .text PROGBITS 00000000 000034 000000 00 AX 0 0 1
|
||||
[ 2] .data PROGBITS 00000000 000034 000000 00 WA 0 0 1
|
||||
[ 3] .bss NOBITS 00000000 000034 000000 00 WA 0 0 1
|
||||
[ 4] .note.GNU-stack PROGBITS 00000000 000034 000000 00 0 0 1
|
||||
[ 5] .gnu_debuglink PROGBITS 00000000 000034 00000c 00 0 0 1
|
||||
[ 6] .shstrtab STRTAB 00000000 000040 00003b 00 0 0 1
|
||||
Key to Flags:
|
||||
W (write), A (alloc), X (execute), M (merge), S (strings)
|
||||
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
|
||||
O (extra OS processing required) o (OS specific), p (processor specific)
|
||||
|
||||
There are no section groups in this file.
|
||||
|
||||
There are no program headers in this file.
|
||||
|
||||
There are no relocations in this file.
|
||||
|
||||
The decoding of unwind sections for machine type Intel 80386 is not currently supported.
|
||||
|
||||
No version information found in this file.
|
||||
8
tools.py
8
tools.py
|
|
@ -459,11 +459,9 @@ objdump_headers.dependencies = {"binutils"}
|
|||
|
||||
|
||||
def objdump_disassemble(path):
|
||||
stdout, *rest = _do_command(
|
||||
["objdump", "--disassemble", "--reloc", "--dynamic-reloc", path])
|
||||
import pygments.lexers.asm
|
||||
lexer = pygments.lexers.asm.ObjdumpLexer()
|
||||
return Status.ok, fill3.Text(list(pygments.lex(stdout, lexer)))
|
||||
return _run_command(
|
||||
["objdump", "--disassemble", "--reloc", "--dynamic-reloc", path],
|
||||
Status.normal)
|
||||
objdump_disassemble.dependencies = {"binutils"}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -140,6 +140,12 @@ class ToolsTestCase(unittest.TestCase):
|
|||
self._sub_tests([(tools.splint, "hello.c", tools.Status.ok),
|
||||
(tools.splint, "hello.h", tools.Status.ok)])
|
||||
|
||||
def test_object_file_tools(self):
|
||||
self._sub_tests([
|
||||
(tools.objdump_headers, "Mcrt1.o", tools.Status.normal),
|
||||
(tools.objdump_disassemble, "Mcrt1.o", tools.Status.problem),
|
||||
(tools.readelf, "Mcrt1.o", tools.Status.normal)])
|
||||
|
||||
def test_unzip(self):
|
||||
self._sub_tests([
|
||||
(tools.unzip, "hi.zip", tools.Status.normal)])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue