[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug binutils/30979] New: objdump --disassemble of a .o file ignores the
From: |
bruno at clisp dot org |
Subject: |
[Bug binutils/30979] New: objdump --disassemble of a .o file ignores the relocations |
Date: |
Wed, 18 Oct 2023 09:40:46 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=30979
Bug ID: 30979
Summary: objdump --disassemble of a .o file ignores the
relocations
Product: binutils
Version: 2.38
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: binutils
Assignee: unassigned at sourceware dot org
Reporter: bruno at clisp dot org
Target Milestone: ---
Created attachment 15178
--> https://sourceware.org/bugzilla/attachment.cgi?id=15178&action=edit
sample object file
When 'objdump' is invoked to disassemble a .o file, it ignores
the relocations and thus prints nonsense for the targets of
calls to functions outside this .o file.
Example: On x64_64:
========================================================================
$ objdump --disassemble fenv-round.o
fenv-round.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <fegetround>:
0: f3 0f 1e fa endbr64
4: 48 83 ec 18 sub $0x18,%rsp
8: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax
f: 00 00
11: 48 89 44 24 08 mov %rax,0x8(%rsp)
16: 31 c0 xor %eax,%eax
18: d9 7c 24 06 fnstcw 0x6(%rsp)
1c: 0f b7 44 24 06 movzwl 0x6(%rsp),%eax
21: 25 00 0c 00 00 and $0xc00,%eax
26: 48 8b 54 24 08 mov 0x8(%rsp),%rdx
2b: 64 48 2b 14 25 28 00 sub %fs:0x28,%rdx
32: 00 00
34: 75 05 jne 3b <fegetround+0x3b>
36: 48 83 c4 18 add $0x18,%rsp
3a: c3 ret
3b: e8 00 00 00 00 call 40 <fesetround>
0000000000000040 <fesetround>:
40: f3 0f 1e fa endbr64
44: 48 83 ec 28 sub $0x28,%rsp
48: 41 89 f8 mov %edi,%r8d
4b: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax
52: 00 00
54: 48 89 44 24 18 mov %rax,0x18(%rsp)
59: 31 c0 xor %eax,%eax
5b: 41 81 e0 ff f3 ff ff and $0xfffff3ff,%r8d
62: 75 5c jne c0 <fesetround+0x80>
64: d9 7c 24 0e fnstcw 0xe(%rsp)
68: 0f b7 54 24 0e movzwl 0xe(%rsp),%edx
6d: 89 d0 mov %edx,%eax
6f: 80 e4 f3 and $0xf3,%ah
72: 09 f8 or %edi,%eax
74: 66 89 44 24 0c mov %ax,0xc(%rsp)
79: 66 39 c2 cmp %ax,%dx
7c: 74 04 je 82 <fesetround+0x42>
7e: d9 6c 24 0c fldcw 0xc(%rsp)
82: 0f ae 5c 24 14 stmxcsr 0x14(%rsp)
87: 8b 54 24 14 mov 0x14(%rsp),%edx
8b: c1 e7 03 shl $0x3,%edi
8e: 89 d0 mov %edx,%eax
90: 80 e4 9f and $0x9f,%ah
93: 09 f8 or %edi,%eax
95: 89 44 24 10 mov %eax,0x10(%rsp)
99: 39 c2 cmp %eax,%edx
9b: 74 05 je a2 <fesetround+0x62>
9d: 0f ae 54 24 10 ldmxcsr 0x10(%rsp)
a2: 48 8b 44 24 18 mov 0x18(%rsp),%rax
a7: 64 48 2b 04 25 28 00 sub %fs:0x28,%rax
ae: 00 00
b0: 75 16 jne c8 <fesetround+0x88>
b2: 44 89 c0 mov %r8d,%eax
b5: 48 83 c4 28 add $0x28,%rsp
b9: c3 ret
ba: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
c0: 41 b8 ff ff ff ff mov $0xffffffff,%r8d
c6: eb da jmp a2 <fesetround+0x62>
c8: e8 00 00 00 00 call cd <fesetround+0x8d>
========================================================================
The last instruction of the first function is particularly misleading:
It looks like a call function <fesetround>. Which it isn't, as can be
seen from
========================================================================
$ objdump --reloc fenv-round.o
fenv-round.o: file format elf64-x86-64
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
000000000000003c R_X86_64_PLT32 __stack_chk_fail-0x0000000000000004
...
========================================================================
or from disassembling an executable that was linked with this object file:
========================================================================
$ objdump --disassemble test-fenv-round
...
0000000000001cb0 <fegetround>:
1cb0: f3 0f 1e fa endbr64
1cb4: 48 83 ec 18 sub $0x18,%rsp
1cb8: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax
1cbf: 00 00
1cc1: 48 89 44 24 08 mov %rax,0x8(%rsp)
1cc6: 31 c0 xor %eax,%eax
1cc8: d9 7c 24 06 fnstcw 0x6(%rsp)
1ccc: 0f b7 44 24 06 movzwl 0x6(%rsp),%eax
1cd1: 25 00 0c 00 00 and $0xc00,%eax
1cd6: 48 8b 54 24 08 mov 0x8(%rsp),%rdx
1cdb: 64 48 2b 14 25 28 00 sub %fs:0x28,%rdx
1ce2: 00 00
1ce4: 75 05 jne 1ceb <fegetround+0x3b>
1ce6: 48 83 c4 18 add $0x18,%rsp
1cea: c3 ret
1ceb: e8 a0 f3 ff ff call 1090 <__stack_chk_fail@plt>
...
========================================================================
Even the combined options --disassemble and --reloc don't produce a
human-readable result:
========================================================================
$ objdump --disassemble --reloc test-fenv-round
...
3b: e8 00 00 00 00 call 40 <fesetround>
3c: R_X86_64_PLT32 __stack_chk_fail-0x4
...
========================================================================
(The "40 <fesetround>" part is still nonsense. And what is the -0x4 here??)
What I would want to see, is:
========================================================================
$ objdump --disassemble test-fenv-round
...
3b: e8 00 00 00 00 call <__stack_chk_fail@plt>
...
========================================================================
Because of this problem, "objdump --disassemble" on .o files is
effectively useless to me in most situations.
$ objdump --version
GNU objdump (GNU Binutils for Ubuntu) 2.38
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug binutils/30979] New: objdump --disassemble of a .o file ignores the relocations,
bruno at clisp dot org <=
- [Bug binutils/30979] objdump --disassemble of a .o file ignores the relocations, bruno at clisp dot org, 2023/10/18
- [Bug binutils/30979] objdump --disassemble of a .o file ignores the relocations, bruno at clisp dot org, 2023/10/18
- [Bug binutils/30979] objdump --disassemble of a .o file ignores the relocations, bruno at clisp dot org, 2023/10/18
- [Bug binutils/30979] objdump --disassemble of a .o file ignores the relocations, address@hidden, 2023/10/18
- [Bug binutils/30979] objdump --disassemble of a .o file ignores the relocations, bruno at clisp dot org, 2023/10/18
- [Bug binutils/30979] objdump --disassemble of a .o file ignores the relocations, address@hidden, 2023/10/18
- [Bug binutils/30979] objdump --disassemble of a .o file ignores the relocations, bruno at clisp dot org, 2023/10/18
- [Bug binutils/30979] objdump --disassemble of a .o file ignores the relocations, address@hidden, 2023/10/18
- [Bug binutils/30979] objdump --disassemble of a .o file ignores the relocations, nickc at redhat dot com, 2023/10/18