For a school project I have to do a large amount of string manipulation in assembly. Since this is a pain to do I was trying to come up with innovative ways to use already programmed string operations. My idea is to compile and dump the assembly from the string.h
library in c. Then I would copy paste the dumped assembly into my program. After figuring out the memory location of each function and it's parameters I figure I would essentially be able to call up the function.
To dump the assembly I first wrote a program that included the libraries I wanted:
#include <stdio.h>
#include <string.h>
int main() {
return 0;
}
Then I compiled and dumped the assembly using
gcc -o lib lib.c
objdump -d *o
When I looked at the output I noticed that it didn't include any of the assembly for the libraries. My guess is there is either a compiler optimization that doesn't include unused functions, or the library output is hidden when I use objdump
:
lib: file format Mach-O 64-bit x86-64
Disassembly of section __TEXT,__text:
__text:
100000fa0: 55 pushq %rbp
100000fa1: 48 89 e5 movq %rsp, %rbp
100000fa4: 31 c0 xorl %eax, %eax
100000fa6: c7 45 fc 00 00 00 00 movl $0, -4(%rbp)
100000fad: 5d popq %rbp
100000fae: c3 retq
_main:
100000fa0: 55 pushq %rbp
100000fa1: 48 89 e5 movq %rsp, %rbp
100000fa4: 31 c0 xorl %eax, %eax
100000fa6: c7 45 fc 00 00 00 00 movl $0, -4(%rbp)
100000fad: 5d popq %rbp
100000fae: c3 retq
As a side note I am running OSX Catalina, but I can switch to Ubuntu or a different OS if it would be easier.
How can I go about dumping the asm for the string.h
library?