Zig Version
0.14.0-dev.2487+af89bb05d
Steps to Reproduce and Observed Behavior
- create file
plt_test.c with content:int imported_function(void);
int exported_function(void){
return imported_function()+1;
} - run
zig cc -target x86_64-linux-gnu -nostdlib -shared -Os -fno-plt -o plt_test_c.so plt_test.c
- run
eu-objdump --disassemble plt_test_c.so
it outputsplt_test_c.so: elf64-elf_x86_64
Disassembly of section .text:
1314: 50 push %rax
1315: ff 15 c5 10 00 00 callq *0x10c5(%rip) # 0x23e0
131b: ff c0 inc %eax
131d: 59 pop %rcx
131e: c3 retqno .plt section because -fno-plt - create file
plt_test.zig with content:extern fn imported_function() callconv(.C) i32;
export fn exported_function() callconv(.C) i32{
return imported_function()+1;
} - run
zig cc -target x86_64-linux-gnu -nostdlib -shared -Os -fno-plt -o plt_test_zig.so plt_test.zig
- run
eu-objdump --disassemble plt_test_zig.so
it outputsplt_test_zig.so: elf64-elf_x86_64
Disassembly of section .text:
1314: 50 push %rax
1315: e8 16 00 00 00 callq 0x1330
131a: ff c0 inc %eax
131c: 59 pop %rcx
131d: c3 retq
Disassembly of section .plt:
1320: ff 35 f2 10 00 00 pushq 0x10f2(%rip) # 0x2418
1326: ff 25 f4 10 00 00 jmpq *0x10f4(%rip) # 0x2420
132c: 0f 1f 40 00 nopl 0x0(%rax)
1330: ff 25 f2 10 00 00 jmpq *0x10f2(%rip) # 0x2428
1336: 68 00 00 00 00 pushq $0x0
133b: e9 e0 ff ff ff jmpq 0x1320.plt section exists, -fno-plt disregarded
Expected Behavior
zig cc -target x86_64-linux-gnu -nostdlib -shared -Os -fno-plt -o plt_test_zig.so plt_test.zig
doesn't generate
.plt section and
eu-objdump --disassemble plt_test_zig.so
outputs
plt_test_zig.so: elf64-elf_x86_64
Disassembly of section .text:
1314: 50 push %rax
1315: ff 15 c5 10 00 00 callq *0x10c5(%rip) # 0x23e0
131b: ff c0 inc %eax
131d: 59 pop %rcx
131e: c3 retq
Zig Version
0.14.0-dev.2487+af89bb05d
Steps to Reproduce and Observed Behavior
plt_test.cwith content:plt_test_c.so: elf64-elf_x86_64 Disassembly of section .text: 1314: 50 push %rax 1315: ff 15 c5 10 00 00 callq *0x10c5(%rip) # 0x23e0 131b: ff c0 inc %eax 131d: 59 pop %rcx 131e: c3 retqno.pltsection because-fno-pltplt_test.zigwith content:plt_test_zig.so: elf64-elf_x86_64 Disassembly of section .text: 1314: 50 push %rax 1315: e8 16 00 00 00 callq 0x1330 131a: ff c0 inc %eax 131c: 59 pop %rcx 131d: c3 retq Disassembly of section .plt: 1320: ff 35 f2 10 00 00 pushq 0x10f2(%rip) # 0x2418 1326: ff 25 f4 10 00 00 jmpq *0x10f4(%rip) # 0x2420 132c: 0f 1f 40 00 nopl 0x0(%rax) 1330: ff 25 f2 10 00 00 jmpq *0x10f2(%rip) # 0x2428 1336: 68 00 00 00 00 pushq $0x0 133b: e9 e0 ff ff ff jmpq 0x1320.pltsection exists,-fno-pltdisregardedExpected Behavior
.pltsection andplt_test_zig.so: elf64-elf_x86_64 Disassembly of section .text: 1314: 50 push %rax 1315: ff 15 c5 10 00 00 callq *0x10c5(%rip) # 0x23e0 131b: ff c0 inc %eax 131d: 59 pop %rcx 131e: c3 retq