elf

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

Convert a statically linked elf binary to dynamically linked

别等时光非礼了梦想. 提交于 2019-12-03 12:19:58
I have a elf binary which has been statically linked to libc. I do not have access to its C code. I would like to use OpenOnload library, which has implementation of sockets in user-space and therefore provides lower latency compared to standard libc versions. OpenOnload implements standard socket api, and overrides libc version using LD_PRELOAD. But, since this elf binary is statically linked, it cannot use the OpenOnload version of the socket API. I believe that converting this binary to dynamically link with OpenOnload is possible, with the following steps: Add new Program headers: PT

Meaning of a Common String In Executables?

我只是一个虾纸丫 提交于 2019-12-03 11:04:54
There appear to be some similar-looking long alphanumeric strings that commonly occur in Mach-O 64 bit executables and ELF 64-bit LSB executables among other symbols that are not alphanumeric: cat /bin/bash | grep -c "AWAVAUATSH" has 181 results, and cat /usr/bin/gzip | grep -c "AWAVAUATSH" has 9 results. What are these strings? Interesting question. Since I didn't know the answer, here are the steps I took to figure it out: Where in the file does the string occur? strings -otx /bin/gzip | grep AWAVAUATUSH 35e0 AWAVAUATUSH 69a0 AWAVAUATUSH 7920 AWAVAUATUSH 8900 AWAVAUATUSH 92a0 AWAVAUATUSH

CPU dependent code: how to avoid function pointers?

╄→гoц情女王★ 提交于 2019-12-03 09:29:36
I have performance critical code written for multiple CPUs. I detect CPU at run-time and based on that I use appropriate function for the detected CPU. So, now I have to use function pointers and call functions using these function pointers: void do_something_neon(void); void do_something_armv6(void); void (*do_something)(void); if(cpu == NEON) { do_something = do_something_neon; }else{ do_something = do_something_armv6; } //Use function pointer: do_something(); ... Not that it matters, but I'll mention that I have optimized functions for different cpu's: armv6 and armv7 with NEON support. The

Any tool/software in windows for viewing ELF file format? [closed]

只愿长相守 提交于 2019-12-03 09:27:44
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . There are lots of PE file browsers. Here is a list of good ones if you are interested: PE File format viewers: PE Explorer http://www.pe-explorer.com/ PE VIew: http://www.magma.ca/~wjr/ PEBrowse Professional http://www.smidgeonsoft.prohosting.com/pebrowse-pro-file-viewer.html PE Browse Professional Interactive -

Edit variable values in ELF file?

依然范特西╮ 提交于 2019-12-03 09:13:05
I need to change a couple of variables in a compiled ELF file. Trying to explain this clearly I'll use a simple C struct as an example. The single source file is compiled and linked (@ 0x1000) into MyFile.elf from MyFile.c: typedef struct { uint32_t SerialNumber; /* Increments for every time it's programmed */ uint32_t PartNumber; /* Always the same */ char ProdDateTime[32]; /* "YYYY-MM-DD HH:MM:SS" date/time when programmed */ uint32_t CalcCrc32; /* Checksum of the above data */ } MyData_T; const MyData_T MyData = { /* SerialNumber */ 0x11111111, /* PartNumber */ 0x12345678, /* ProdDateTime

Clarification on Binary file (PE/COFF & ELF) formats & terminology

回眸只為那壹抹淺笑 提交于 2019-12-03 09:10:54
问题 I'm confusing little in terminology. A file that is given as input to the linker is called Object File . The linker produces an Image file , which in turn is used as input by the loader. I got this from "MS PE & COFF Specification" Q1. Image file is also referred to as Binary Image , Binary File or just Binary . Right? Q2. So, according to the above stated terminology, the PE/ELF/COFF are the formats of Image File & not the Object File. right? But http://www.sco.com/developers/gabi/latest/ch4

CentOS 64 bit bad ELF interpreter

匿名 (未验证) 提交于 2019-12-03 08:59:04
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have just installed CentOS 6 64bit version, I'm trying to install a 32-bit application on a 64-bit machine and got this error: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory I'm new to linux. How do I resolve this? 回答1: You're on a 64-bit system, and don't have 32-bit library support installed. To install (baseline) support for 32-bit executables Most desktop Linux systems in the Fedora/Red Hat family: pkcon install glibc.i686 Possibly some desktop Debian/Ubuntu systems?: pkcon install ia32-libs Fedora or newer Red Hat,

How to debug program with custom elf interpreter?

匿名 (未验证) 提交于 2019-12-03 08:59:04
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I can debug some program (say /bin/ls) like this: [ks@localhost ~]$ gdb -q --args /bin/ls Reading symbols from /bin/ls...Reading symbols from /bin/ls...(no debugging symbols found)...done. (no debugging symbols found)...done. Missing separate debuginfos, use: debuginfo-install coreutils-8.22-19.fc21.x86_64 (gdb) start Temporary breakpoint 1 at 0x402990 Starting program: /usr/bin/ls [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Temporary breakpoint 1, 0x0000000000402990 in main ()

ELF format manipulation

邮差的信 提交于 2019-12-03 08:39:10
I have a requirement where I want to associate an index with a file(in a certain format). I was wondering if I can do any ELF manipulation and still ensure that, consistency is maintained so, the file works fine on linux. The idea here is to create a file format which can be queried by a certain API[self-defined] to get me the index. a)is it possible to modify the ELF header to store the index(mentioned above). b)if yes, what is the process? You can add a new ELF section with whatever data you want to an existing executable. e.g. $ echo 42 > /tmp/index $ objcopy --add-section .my_index=/tmp