binutils

How can the --add-section switch of OBJCOPY be used?

僤鯓⒐⒋嵵緔 提交于 2021-02-18 22:53:41
问题 There are really two questions that revolve around the use of --add-section. The simple one is in the title. Based on my reading, I haven't been able to figure out how one could execute --add-section. To use add-section, I have to pass a section name. If I use an existing section name the program responds with "can't add section '.data': File in wrong format." Perhaps I just need to pass another parameter. If I use a new section name, which I would prefer to do, I'm warned that "allocated

How can the --add-section switch of OBJCOPY be used?

旧街凉风 提交于 2021-02-18 22:53:13
问题 There are really two questions that revolve around the use of --add-section. The simple one is in the title. Based on my reading, I haven't been able to figure out how one could execute --add-section. To use add-section, I have to pass a section name. If I use an existing section name the program responds with "can't add section '.data': File in wrong format." Perhaps I just need to pass another parameter. If I use a new section name, which I would prefer to do, I'm warned that "allocated

Binutils LD creates huge files

让人想犯罪 __ 提交于 2021-02-09 11:12:46
问题 I'm trying to create as small ELF as possible. I created a test file like this (NASM syntax): SECTION .text dd 0xdeadbeef With this linker script: SECTIONS { .text : { *(.text) } } Then I checked sizes of flat binary and ELFs built two ways: nasm -f bin -o test test.asm It's flat binary, so 4 bytes. nasm -f elf -o test.o test.asm i686-elf-ld -Tlinker.ld test.o -o test I'd expect something like 500 bytes max, but the resulting file is 4396 bytes long! There is an option however, named --strip

Binutils LD creates huge files

不问归期 提交于 2021-02-09 11:12:05
问题 I'm trying to create as small ELF as possible. I created a test file like this (NASM syntax): SECTION .text dd 0xdeadbeef With this linker script: SECTIONS { .text : { *(.text) } } Then I checked sizes of flat binary and ELFs built two ways: nasm -f bin -o test test.asm It's flat binary, so 4 bytes. nasm -f elf -o test.o test.asm i686-elf-ld -Tlinker.ld test.o -o test I'd expect something like 500 bytes max, but the resulting file is 4396 bytes long! There is an option however, named --strip

Binutils LD creates huge files

安稳与你 提交于 2021-02-09 11:11:23
问题 I'm trying to create as small ELF as possible. I created a test file like this (NASM syntax): SECTION .text dd 0xdeadbeef With this linker script: SECTIONS { .text : { *(.text) } } Then I checked sizes of flat binary and ELFs built two ways: nasm -f bin -o test test.asm It's flat binary, so 4 bytes. nasm -f elf -o test.o test.asm i686-elf-ld -Tlinker.ld test.o -o test I'd expect something like 500 bytes max, but the resulting file is 4396 bytes long! There is an option however, named --strip

What's the “correct” way to determine target and architecture for GNU binutils?

拟墨画扇 提交于 2021-02-07 20:52:23
问题 In my build chain, I need to do this: objcopy -I binary -O $BFDNAME -B $BFDARCH <this> <that> in order to get a binary file into library form. Because I want other people to be able to use this, I need to know how to get $BFDNAME and $BFDARCH from their toolchain when they run the build. I can get the values locally by running objdump -f against a file I've already built, but is there a better way which won't leave me compiling throw-away files just to get configuration values? 回答1: Thank you

How to see what version of Binutils is on Ubuntu?

╄→尐↘猪︶ㄣ 提交于 2021-02-07 05:02:27
问题 I have searched, but not found an option that tells me what version of binutils I have on My Ubuntu. Or at least I don't know how to interpret it. gcc -v - tells nothing about binutils ld -v - tells me GNU ld (GNU Binutils for Ubuntu) 2.24 . Does this means that I have binutils 2.24? 回答1: Yes, with ld -v you can view the version of binutils (in your case is 2.24) 回答2: I tested it only with the Debian 8, but I think it must be working with other Debian-based operation systems (Ubuntu, Mint,

Wrong line numbers from addr2line

人盡茶涼 提交于 2021-02-04 10:40:28
问题 I try to find the exact line of a call in the backtrace in C++ program. Right now I am using these lines (from the man page of backtrace) to get the trace: void *bt_buffer[1000]; char **bt_strings; int bt_nptrs = backtrace(bt_buffer, 1000); bt_strings = backtrace_symbols(bt_buffer, bt_nptrs); In bt_strings I find lines of the form ./prog() [0x402e42] Now I take the address (the hex string) and feed it to addr2line. That sometimes results in apparently wrong line numbers. Internet search led