elf

Arm: How does objcopy know which sections from an elf to include in a binary or ihex?

情到浓时终转凉″ 提交于 2019-12-09 22:49:12
问题 I'm working on a project which involves parsing an arm elf file and extracting the sections from it. There are obviously plenty of sections in an elf file which do not get loaded into flash, but I'm wondering how exactly objcopy knows which sections to include in a binary to be flashed directly into flash? Take for example the following readelf of an arm elf file: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .isr_vector PROGBITS

Is the ELF .notes section really needed?

陌路散爱 提交于 2019-12-09 17:21:27
问题 On Linux, I'm trying to strip a statically linked ELF file to the bare essentials. When I run: strip --strip-unneeded foo or strip --strip-all foo The resulting file still has a fat .notes section that appears to be full of funky strings. Is the .notes section really needed or can I safely force it out with --remove-section? Thanks for any help. 回答1: From experience and from looking at the man page for strip , it looks like strip isn't supposed to get rid of any and all sections and strings

How can I find the dynamic libraries required by an ELF Binary in C++?

时光毁灭记忆、已成空白 提交于 2019-12-09 12:21:36
问题 How can I get a list of all the dynamic libraries that is required by an elf binary in linux using C++? Once I've managed to extract the information (filename?) from the binary I can find the actual file by searching through the PATH , but I haven't been able to find any information regarding extracting unmangled information from the ELF binary. Thoughts? 回答1: The list of required shared objects is stored in the so-called dynamic section of the executable. The rough algorithm of getting the

Patching code/symbols into a dynamic-linked ELF binary

大兔子大兔子 提交于 2019-12-09 10:37:37
问题 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

Convert a statically linked elf binary to dynamically linked

断了今生、忘了曾经 提交于 2019-12-09 09:35:48
问题 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

ELF format manipulation

坚强是说给别人听的谎言 提交于 2019-12-09 06:46:42
问题 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? 回答1: You can add a new ELF section with whatever

COFF on Linux or ELF on Windows

余生颓废 提交于 2019-12-09 02:28:02
问题 Is it possible to run the COFF executable files on UNIX or the ELF executable files on Windows? And what would be the steps to be able to run either file type on Windows and UNIX. I'm just curious. 回答1: To actually run executables and have them do useful stuff, you need to worry about the API, not just the executable file format. On a Linux machine with WINE installed, you can run Windows .EXE files from the command line and they do the same thing that they do on Windows. The other way around

How to run a bare metal ELF file on QEMU?

南楼画角 提交于 2019-12-09 02:02:26
问题 How do you run an elf file on QEMU? This is my best guess: qemu-system-i386 -hda kernel.elf Does this work? The elf file is a kernel generated from this tutorial. 回答1: Simply use -kernel option: qemu-system-i386 -kernel kernel.elf 回答2: Minimal runnable example Source: https://github.com/cirosantilli/aarch64-bare-metal-qemu/tree/27537fb1dd0c27d6d91516bf4fc7e1d9564f5a40 Run with: make qemu-system-aarch64 -M virt -cpu cortex-a57 -nographic -kernel test64.elf -serial mon:stdio Outcome: prints a

how about .bss section not zero initialized

穿精又带淫゛_ 提交于 2019-12-09 00:09:59
问题 as we know .bss contains un-initialized variables. if in c code, programer initialize the variables before using them. then .bss is not necessary to be zero before executing C code. Am I right? Thanks 回答1: In C code, any variable with static storage duration is defined to be initialized to 0 by the spec (Section 6.7.8 Initialization, paragraph 10): If an object that has static storage duration is not initialized explicitly, then: if it has pointer type, it is initialized to a null pointer; if

Proxy shared library (sharedlib, shlib, so) for ELF?

浪子不回头ぞ 提交于 2019-12-08 19:22:55
问题 On Windows, it's more or less common to create "proxy DLLs" which take place of the original DLL and forward calls to it (after any additional actions as needed). You can read about it here and here for example. However, shlib munging culture under Linux is quite different. It starts with the fact that LD_PRELOAD is the builtin feature with ld.so under Linux, which simply injects separate shlib into process and uses any symbols it defines as override. And that "injection" technique seems to