Skip to content

[tool][objdump] llvm-objdump in arrch32 disassembly couldn't print callee symbol, just only address #80385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Zhenhang1213 opened this issue Feb 2, 2024 · 3 comments

Comments

@Zhenhang1213
Copy link
Contributor

Zhenhang1213 commented Feb 2, 2024

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int func()
{
	char c = 'b';
	char str1[8];
	memset(str1, c, 8);
	return 0;
}
int main()
{
	func();
	return 0;
}

On a 32-bit architecture, when I compile this code into an object file and disassemble it using the objdump tool, the generated assembly instructions do not have the __stack_chk_fail function call, however arrch64 not, when target is arrch64 or x86.

llvm-objdump -d demo.o

The corresponding binary files of 32bit and arrch64 are as follows:
demo.zip

@llvmbot
Copy link
Member

llvmbot commented Feb 2, 2024

@llvm/issue-subscribers-tools-llvm-objdump

Author: None (Zhenhang1213)

`#include <stdio.h> #include <stdlib.h> #include <string.h>

int func()
{
char c = 'b';
char str1[8];

//set
memset(str1, c, 8);
str1[7] = '\0';

//get
printf("str1=%s\n", str1);

return 0;

}

int main()
{
func();
return 0;
}
`

On a 32-bit architecture, when I compile this code into an object file and disassemble it using the objdump tool, the generated assembly instructions do not have the __stack_chk_fail function call, however arrch64 not.

Both 32-bit architecture and arrch64 directly generated assembly instructions have __stack_chk_fail function call
https://godbolt.org/z/cPvhj3n4b

clang demo.c -fstack-protector

@Zhenhang1213
Copy link
Contributor Author

Zhenhang1213 commented Feb 4, 2024

32bit:
000005c4 :
5c4: e92d4800 push {r11, lr}
5c8: e1a0b00d mov r11, sp
........
62c: e3000000 movw r0, #0
630: e1a0d00b mov sp, r11
634: e8bd8800 pop {r11, pc}
638: ebffff81 bl 0x444 <.plt+0x2c> @ imm = #-508 <<<<----- There is the difference

64bit:
00000000000007f0 :
7f0: d100c3ff sub sp, sp, #48
.......
848: 14000001 b 0x84c <func+0x5c>
84c: 97ffff95 bl 0x6a0 __stack_chk_fail@plt <<<----- There is the difference
850: 2a1f03e0 mov w0, wzr
854: a9427bfd ldp x29, x30, [sp, #32]
858: 9100c3ff add sp, sp, #48
85c: d65f03c0 ret

@Zhenhang1213 Zhenhang1213 changed the title [tool][objdump] llvm-objdump in arrch32 disassembly without __stack_chk_fail while applying -fstack-protector [tool][objdump] llvm-objdump in arrch32 disassembly couldn't print callee symbol, just only address Feb 4, 2024
@Zhenhang1213
Copy link
Contributor Author

@Bigcheese

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants