Skip to content

Instantly share code, notes, and snippets.

@evanrichter
Created February 15, 2022 03:22
Show Gist options
  • Select an option

  • Save evanrichter/95c951105876381f2868cd406571840c to your computer and use it in GitHub Desktop.

Select an option

Save evanrichter/95c951105876381f2868cd406571840c to your computer and use it in GitHub Desktop.
mold miscompile i686 linux musl
[evan@arch asdf]$ rustc --emit=obj --target=i686-unknown-linux-musl -C opt-level=3 -C link-arg=-fuse-ld=/usr/bin/mold -C link-arg=-Wl,--image-base=0x40000,-v -C linker=/usr/bin/clang -C link-arg=-v src/main.rs
[evan@arch asdf]$ file main.o
main.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
[evan@arch asdf]$ objdump -dr main.o
main.o: file format elf32-i386
Disassembly of section .text._ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h7e3e23934c3cb896E:
00000000 <_ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h7e3e23934c3cb896E>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 53 push %ebx
4: 50 push %eax
5: e8 00 00 00 00 call a <_ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h7e3e23934c3cb896E+0xa>
a: 5b pop %ebx
b: 81 c3 03 00 00 00 add $0x3,%ebx
d: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
11: ff d1 call *%ecx
13: 83 c4 04 add $0x4,%esp
16: 5b pop %ebx
17: 5d pop %ebp
18: c3 ret
Disassembly of section .text._ZN3std2rt10lang_start17h34774707aaac6679E:
00000000 <_ZN3std2rt10lang_start17h34774707aaac6679E>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 53 push %ebx
4: 56 push %esi
5: 83 ec 10 sub $0x10,%esp
8: 8b 55 08 mov 0x8(%ebp),%edx
b: 8b 4d 10 mov 0x10(%ebp),%ecx
e: 8b 45 0c mov 0xc(%ebp),%eax
11: e8 00 00 00 00 call 16 <_ZN3std2rt10lang_start17h34774707aaac6679E+0x16>
16: 5b pop %ebx
17: 8d 75 f4 lea -0xc(%ebp),%esi
1a: 81 c3 06 00 00 00 add $0x6,%ebx
1c: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
20: 89 55 f4 mov %edx,-0xc(%ebp)
23: 8d 93 00 00 00 00 lea 0x0(%ebx),%edx
25: R_386_GOTOFF .data.rel.ro..L__unnamed_1
29: 51 push %ecx
2a: 50 push %eax
2b: 52 push %edx
2c: 56 push %esi
2d: e8 fc ff ff ff call 2e <_ZN3std2rt10lang_start17h34774707aaac6679E+0x2e>
2e: R_386_PLT32 _ZN3std2rt19lang_start_internal17h507df075b55a5f12E
32: 83 c4 20 add $0x20,%esp
35: 5e pop %esi
36: 5b pop %ebx
37: 5d pop %ebp
38: c3 ret
Disassembly of section .text._ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17ha810b554e846830fE:
00000000 <_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17ha810b554e846830fE>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 53 push %ebx
4: 50 push %eax
5: 8b 45 08 mov 0x8(%ebp),%eax
8: e8 00 00 00 00 call d <_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17ha810b554e846830fE+0xd>
d: 5b pop %ebx
e: 81 c3 03 00 00 00 add $0x3,%ebx
10: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
14: 8b 08 mov (%eax),%ecx
16: e8 fc ff ff ff call 17 <_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17ha810b554e846830fE+0x17>
17: R_386_PC32 .text._ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h7e3e23934c3cb896E
1b: 31 c0 xor %eax,%eax
1d: 83 c4 04 add $0x4,%esp
20: 5b pop %ebx
21: 5d pop %ebp
22: c3 ret
Disassembly of section .text._ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h6f3a4ea374c0f043E:
00000000 <_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h6f3a4ea374c0f043E>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 53 push %ebx
4: 50 push %eax
5: 8b 45 08 mov 0x8(%ebp),%eax
8: e8 00 00 00 00 call d <_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h6f3a4ea374c0f043E+0xd>
d: 5b pop %ebx
e: 81 c3 03 00 00 00 add $0x3,%ebx
10: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
14: 8b 08 mov (%eax),%ecx
16: e8 fc ff ff ff call 17 <_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h6f3a4ea374c0f043E+0x17>
17: R_386_PC32 .text._ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h7e3e23934c3cb896E
1b: 31 c0 xor %eax,%eax
1d: 83 c4 04 add $0x4,%esp
20: 5b pop %ebx
21: 5d pop %ebp
22: c3 ret
Disassembly of section .text._ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17hd709d1f42d2bf59eE:
00000000 <_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17hd709d1f42d2bf59eE>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 5d pop %ebp
4: c3 ret
Disassembly of section .text._ZN4main4main17h5ea8adc459579547E:
00000000 <_ZN4main4main17h5ea8adc459579547E>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 53 push %ebx
4: 50 push %eax
5: e8 00 00 00 00 call a <_ZN4main4main17h5ea8adc459579547E+0xa>
a: 5b pop %ebx
b: 81 c3 03 00 00 00 add $0x3,%ebx
d: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
11: e8 fc ff 33 12 call 12340012 <_ZN4main4main17h5ea8adc459579547E+0x12340012>
12: R_386_PC32 *ABS*
16: 83 c4 04 add $0x4,%esp
19: 5b pop %ebx
1a: 5d pop %ebp
1b: c3 ret
Disassembly of section .text.main:
00000000 <main>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 53 push %ebx
4: 56 push %esi
5: 83 ec 10 sub $0x10,%esp
8: 8b 4d 0c mov 0xc(%ebp),%ecx
b: e8 00 00 00 00 call 10 <main+0x10>
10: 5b pop %ebx
11: 8b 45 08 mov 0x8(%ebp),%eax
14: 8d 75 f4 lea -0xc(%ebp),%esi
17: 81 c3 09 00 00 00 add $0x9,%ebx
19: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
1d: 8d 93 00 00 00 00 lea 0x0(%ebx),%edx
1f: R_386_GOTOFF .text._ZN4main4main17h5ea8adc459579547E
23: 89 55 f4 mov %edx,-0xc(%ebp)
26: 8d 93 00 00 00 00 lea 0x0(%ebx),%edx
28: R_386_GOTOFF .data.rel.ro..L__unnamed_1
2c: 51 push %ecx
2d: 50 push %eax
2e: 52 push %edx
2f: 56 push %esi
30: e8 fc ff ff ff call 31 <main+0x31>
31: R_386_PLT32 _ZN3std2rt19lang_start_internal17h507df075b55a5f12E
35: 83 c4 20 add $0x20,%esp
38: 5e pop %esi
39: 5b pop %ebx
3a: 5d pop %ebp
3b: c3 ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment