binutils

Patching code/symbols into a dynamic-linked ELF binary

谁都会走 提交于 2019-12-03 13:41:41
Suppose I have an ELF binary that's dynamic linked, and I want to override/redirect certain library calls. I know I can do this with LD_PRELOAD , but I want a solution that's permanent in the binary, independent of the environment, and that works for setuid/setgid binaries, none of which LD_PRELOAD can achieve. What I'd like to do is add code from additional object files (possibly in new sections, if necessary) and add the symbols from these object files to the binary's symbol table so that the newly added version of the code gets used in place of the shared library code. I believe this should

Unresolvable `R_X86_64_NONE` relocation

情到浓时终转凉″ 提交于 2019-12-03 06:57:24
I'm using Devtoolset-7 on CentOS 7 and have built Boost 1.65.1 w/ it. But when I link my application, I've got the following: /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt/rh/devtoolset-7/root/usr/lib64/libboost_unit_test_framework.a(compiler_log_formatter.o)(.text._ZN5boost9unit_test5utils11string_castINS0_13basic_cstringIKcEEEESsRKT_[_ZN5boost9unit_test5utils11string_castINS0_13basic_cstringIKcEEEESsRKT_]+0x3c): unresolvable R_X86_64_NONE relocation against symbol `_ZTVSt9basic_iosIcSt11char_traitsIcEE@@GLIBCXX_3.4' /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64

Difference between nm and objdump

邮差的信 提交于 2019-12-03 06:04:44
问题 Looking at the manuals, objdump and nm have overlapping features. When would you use each one? What was the original purpose of each command? 回答1: They have no similar parameters. nm lists file symbols, while objdump can show a lot of different information about files. objdump can shows symbols too, and it is explicitly noted in the manpage that "This is similar to the information provided by the nm program, although the display format is different." 回答2: It seems like nm is posix, so

How to deal with recursive dependencies between static libraries using the binutils linker?

时光怂恿深爱的人放手 提交于 2019-12-03 05:57:13
问题 I'm porting an existing system from Windows to Linux. The build is structured with multiple static libraries. I ran into a linking error where a symbol (defined in libA) could not be found in an object from libB. The linker line looked like g++ test_obj.o -lA -lB -o test The problem of course being that by the time the linker finds it needs the symbol from libA, it has already passed it by, and does not rescan, so it simply errors out even though the symbol is there for the taking. My initial

How to deal with recursive dependencies between static libraries using the binutils linker?

a 夏天 提交于 2019-12-02 19:20:15
I'm porting an existing system from Windows to Linux. The build is structured with multiple static libraries. I ran into a linking error where a symbol (defined in libA) could not be found in an object from libB. The linker line looked like g++ test_obj.o -lA -lB -o test The problem of course being that by the time the linker finds it needs the symbol from libA, it has already passed it by, and does not rescan, so it simply errors out even though the symbol is there for the taking. My initial idea was of course to simply swap the link (to -lB -lA) so that libA is scanned afterwards, and any

Binutils build fails on Mac OS X 10.10.5 Yosemite

落爺英雄遲暮 提交于 2019-12-02 16:13:09
问题 After downloading the package of GNU Binutils 2.25 I followed the instructions on "Installing Binutils": ./cnofigure make errors happened after build: ../../binutils-gdb/binutils/nm.c:1733:28: error: 'sbrk' is deprecated [-Werror,-Wdeprecated-declarations] char *lim = (char *) sbrk (0); /usr/include/unistd.h:582:7: note: 'sbrk' has been explicitly marked deprecated here void *sbrk(int); 1 error generated. make[4]: *** [nm.o] Error 1 make[3]: *** [all-recursive] Error 1 make[2]: *** [all]

Binutils build fails on Mac OS X 10.10.5 Yosemite

 ̄綄美尐妖づ 提交于 2019-12-02 09:18:42
After downloading the package of GNU Binutils 2.25 I followed the instructions on "Installing Binutils": ./cnofigure make errors happened after build: ../../binutils-gdb/binutils/nm.c:1733:28: error: 'sbrk' is deprecated [-Werror,-Wdeprecated-declarations] char *lim = (char *) sbrk (0); /usr/include/unistd.h:582:7: note: 'sbrk' has been explicitly marked deprecated here void *sbrk(int); 1 error generated. make[4]: *** [nm.o] Error 1 make[3]: *** [all-recursive] Error 1 make[2]: *** [all] Error 2 make[1]: *** [all-binutils] Error 2 make: *** [all] Error 2 I did some research on net and they

Is it possible to use MIPS register names with GAS (GNU assembler)?

我与影子孤独终老i 提交于 2019-12-02 07:42:23
问题 If I use register names I get: Error: illegal operands `add $t0,$zero,$zero' If I use register number ( $8 instead of $t0 and $0 instead of $zero ) it works. (I'm using binutils 2.17). 回答1: The GNU assembler doesn't support symbolic register names directly. A common approach, if using gcc to drive the assembler, is to use the ".S" extension for the assembler source file (which tells gcc to pass the source through the C preprocessor before the assembler) and #include a header file containing

Is it possible to use MIPS register names with GAS (GNU assembler)?

好久不见. 提交于 2019-12-02 04:28:11
If I use register names I get: Error: illegal operands `add $t0,$zero,$zero' If I use register number ( $8 instead of $t0 and $0 instead of $zero ) it works. (I'm using binutils 2.17). The GNU assembler doesn't support symbolic register names directly. A common approach, if using gcc to drive the assembler, is to use the ".S" extension for the assembler source file (which tells gcc to pass the source through the C preprocessor before the assembler) and #include a header file containing definitions like: #define zero $0 #define v0 $2 #define v1 $3 Then the assembler source can have statements

Elegant way to set base address of ELF image with Linux binutils?

扶醉桌前 提交于 2019-12-02 01:56:29
For a personal project, I need to write an executable that loads at a non-default memory address. From this SO question , I know I can set the entry address for an ELF and modify the section addresses manually so that the executable is effectively based at some address I choose. However, the answer suggests that this is only works if I don't glibc initialization (which I need for this project), and setting section memory addresses every time I compile would be difficult (not to mention tedious). It seems like there should be a better way to set a base address for an ELF when building, though I