Skip to content
Snippets Groups Projects
Commit 3e72c1c3 authored by Jean-Romain Garnier's avatar Jean-Romain Garnier Committed by Chris Lamb
Browse files

Remove offsets before instructions in objdump

parent e9e29040
No related branches found
No related tags found
No related merge requests found
Pipeline #152273 passed
...@@ -202,6 +202,9 @@ class ReadelfStringSection(ReadElfSection): ...@@ -202,6 +202,9 @@ class ReadelfStringSection(ReadElfSection):
class ObjdumpSection(Command): class ObjdumpSection(Command):
# Remove offsets before instructions (see issue #17)
RE_INSTRUCTION_OFFSET = re.compile(rb"^\s*[0-9a-f]+:")
def __init__(self, path, section_name, *args, **kwargs): def __init__(self, path, section_name, *args, **kwargs):
self._path = path self._path = path
self._path_bin = path.encode("utf-8") self._path_bin = path.encode("utf-8")
...@@ -226,7 +229,7 @@ class ObjdumpSection(Command): ...@@ -226,7 +229,7 @@ class ObjdumpSection(Command):
if line.startswith(b"In archive"): if line.startswith(b"In archive"):
return b"" return b""
return line return ObjdumpSection.RE_INSTRUCTION_OFFSET.sub(b"", line)
class ObjdumpDisassembleSection(ObjdumpSection): class ObjdumpDisassembleSection(ObjdumpSection):
...@@ -248,8 +251,9 @@ class ObjdumpDisassembleSection(ObjdumpSection): ...@@ -248,8 +251,9 @@ class ObjdumpDisassembleSection(ObjdumpSection):
] ]
def filter(self, line): def filter(self, line):
line = super().filter(line) # Apply this filter first as super() removes offsets
return ObjdumpDisassembleSection.RE_SYMBOL_COMMENT.sub(r"\1", line) line = ObjdumpDisassembleSection.RE_SYMBOL_COMMENT.sub(r"\1", line)
return super().filter(line)
class ObjdumpDisassembleSectionNoLineNumbers(ObjdumpDisassembleSection): class ObjdumpDisassembleSectionNoLineNumbers(ObjdumpDisassembleSection):
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
0000000000000000 <f>: 0000000000000000 <f>:
f(): f():
0: push %rbp push %rbp
1: mov %rsp,%rbp mov %rsp,%rbp
- 4: mov $0x2a,%eax - mov $0x2a,%eax
+ 4: mov $0xffffffff,%eax + mov $0xffffffff,%eax
9: pop %rbp pop %rbp
a: retq retq
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
0000000000000000 <f>: 0000000000000000 <f>:
f(): f():
0: push %rbp push %rbp
1: mov %rsp,%rbp mov %rsp,%rbp
- 4: mov $0x2a,%eax - mov $0x2a,%eax
+ 4: mov $0xffffffff,%eax + mov $0xffffffff,%eax
9: pop %rbp pop %rbp
a: retq retq
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
0000000000000000 <return42_or_3>: 0000000000000000 <return42_or_3>:
return42_or_3(): return42_or_3():
0: push %rbp push %rbp
1: mov %rsp,%rbp mov %rsp,%rbp
- 4: mov $0x2a,%eax - mov $0x2a,%eax
+ 4: mov $0x2b,%eax + mov $0x2b,%eax
9: pop %rbp pop %rbp
a: retq retq
@@ -6,15 +6,15 @@ @@ -6,15 +6,15 @@
0000000000000000 <__rust_reallocate>: 0000000000000000 <__rust_reallocate>:
__rust_reallocate(): __rust_reallocate():
0: push %r15 push %r15
2: push %r14 push %r14
4: push %r12 push %r12
6: push %rbx push %rbx
7: push %rax push %rax
- 8: mov %rdx,%rbx - mov %rdx,%rbx
+ 8: mov %rdx,%rcx + mov %rdx,%rcx
b: mov %rsi,%r15 mov %rsi,%r15
e: mov %rdi,%r14 mov %rdi,%r14
11: cmp $0x10,%rcx cmp $0x10,%rcx
15: ja 2d <__rust_reallocate+0x2d> ja 2d <__rust_reallocate+0x2d>
17: mov %r14,%rdi mov %r14,%rdi
1a: mov %rbx,%rsi mov %rbx,%rsi
1d: add $0x8,%rsp add $0x8,%rsp
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment