ld

what is segment 00 in my Linux executable program (64 bits)

让人想犯罪 __ 提交于 2021-01-03 09:41:31
问题 Here is a very simple assembly program, just return 12 after executed. $ cat a.asm global _start section .text _start: mov rax, 60 ; system call for exit mov rdi, 12 ; exit code 12 syscall It can be built and executed correctly: $ nasm -f elf64 a.asm && ld a.o && ./a.out || echo $? 12 But the size of a.out is big, it is more than 4k: $ wc -c a.out 4664 a.out I try to understand it by reading elf content: $ readelf -l a.out Elf file type is EXEC (Executable file) Entry point 0x401000 There are

what is segment 00 in my Linux executable program (64 bits)

可紊 提交于 2021-01-03 09:29:38
问题 Here is a very simple assembly program, just return 12 after executed. $ cat a.asm global _start section .text _start: mov rax, 60 ; system call for exit mov rdi, 12 ; exit code 12 syscall It can be built and executed correctly: $ nasm -f elf64 a.asm && ld a.o && ./a.out || echo $? 12 But the size of a.out is big, it is more than 4k: $ wc -c a.out 4664 a.out I try to understand it by reading elf content: $ readelf -l a.out Elf file type is EXEC (Executable file) Entry point 0x401000 There are

How would you list the available functions etc contained within a compiled library?

旧街凉风 提交于 2020-12-21 17:46:03
问题 How do I determine whether a function exists within a library, or list out the functions in a compiled library? 回答1: You can use the nm command to list the symbols in static libraries. nm -g -C <libMylib.a> 回答2: For ELF binaries, you can use readelf: readelf -sW a.out | awk '$4 == "FUNC"' | c++filt -s : list symbols -W : don't cut too long names The awk command will then filter out all functions, and c++filt will unmangle them. That means it will convert them from an internal naming scheme so

How would you list the available functions etc contained within a compiled library?

耗尽温柔 提交于 2020-12-21 17:41:31
问题 How do I determine whether a function exists within a library, or list out the functions in a compiled library? 回答1: You can use the nm command to list the symbols in static libraries. nm -g -C <libMylib.a> 回答2: For ELF binaries, you can use readelf: readelf -sW a.out | awk '$4 == "FUNC"' | c++filt -s : list symbols -W : don't cut too long names The awk command will then filter out all functions, and c++filt will unmangle them. That means it will convert them from an internal naming scheme so

How would you list the available functions etc contained within a compiled library?

a 夏天 提交于 2020-12-21 17:40:51
问题 How do I determine whether a function exists within a library, or list out the functions in a compiled library? 回答1: You can use the nm command to list the symbols in static libraries. nm -g -C <libMylib.a> 回答2: For ELF binaries, you can use readelf: readelf -sW a.out | awk '$4 == "FUNC"' | c++filt -s : list symbols -W : don't cut too long names The awk command will then filter out all functions, and c++filt will unmangle them. That means it will convert them from an internal naming scheme so

gcc linking specific file in archive

╄→尐↘猪︶ㄣ 提交于 2020-12-15 04:57:51
问题 Have a library os.lib which has many objects archived like kernel.o semaphor.o..etc need to place the specific section of object file in os.lib to a flash location using gcc linker script SECTIONS { .text : { os.lib:kernel.o(.text) } } But does not seem to work! ld throws error kernel.o not found. tried this and also archive:file mentioned in this does not work tool chain: arm-none-eabi-ld 来源: https://stackoverflow.com/questions/65092280/gcc-linking-specific-file-in-archive

discard unused functions in GCC [duplicate]

两盒软妹~` 提交于 2020-12-13 12:13:00
问题 This question already has answers here : How to remove unused C/C++ symbols with GCC and ld? (11 answers) Closed 4 years ago . I need some help for compiling with GCC under MinGW. Say I have 2 files: a.c contains 2 functions a1 and a2 b.c contains 2 functions b1 and b2. Then I link the 2 objects into a shared library. The command used are like: gcc -c a.c gcc -c b.c gcc -shared -Wl, --version-script v.ver -Wl, -Map=out.map -Wl, --strip-all -o mydll.dll a.o b.o v.ver looks like: mylib { global

discard unused functions in GCC [duplicate]

我与影子孤独终老i 提交于 2020-12-13 12:07:15
问题 This question already has answers here : How to remove unused C/C++ symbols with GCC and ld? (11 answers) Closed 4 years ago . I need some help for compiling with GCC under MinGW. Say I have 2 files: a.c contains 2 functions a1 and a2 b.c contains 2 functions b1 and b2. Then I link the 2 objects into a shared library. The command used are like: gcc -c a.c gcc -c b.c gcc -shared -Wl, --version-script v.ver -Wl, -Map=out.map -Wl, --strip-all -o mydll.dll a.o b.o v.ver looks like: mylib { global

Linking a program using printf with ld?

浪尽此生 提交于 2020-11-29 08:33:15
问题 I'm getting a undefined reference to _printf when building an assembly program that defines its own _start instead of main , using NASM on x86-64 Ubuntu Build commands: nasm -f elf64 hello.asm ld -s -o hello hello.o hello.o: In function `_start': hello.asm:(.text+0x1a): undefined reference to `_printf' MakeFile:4: recipe for target 'compile' failed make: *** [compile] Error 1 nasm source: extern _printf section .text global _start _start: mov rdi, format ; argument #1 mov rsi, message ;

Linking a program using printf with ld?

喜夏-厌秋 提交于 2020-11-29 08:32:05
问题 I'm getting a undefined reference to _printf when building an assembly program that defines its own _start instead of main , using NASM on x86-64 Ubuntu Build commands: nasm -f elf64 hello.asm ld -s -o hello hello.o hello.o: In function `_start': hello.asm:(.text+0x1a): undefined reference to `_printf' MakeFile:4: recipe for target 'compile' failed make: *** [compile] Error 1 nasm source: extern _printf section .text global _start _start: mov rdi, format ; argument #1 mov rsi, message ;