elf

How to find load relocation for a PIE binary?

时间秒杀一切 提交于 2021-02-05 04:59:00
问题 I need to get base address of stack inside my running process. This would enable me to print raw stacktraces that will be understood by addr2line (running binary is stripped, but addr2line has access to symbols). I managed to do this by examining elf header of argv[0] : I read entry point and substract it from &_start : #include <stdio.h> #include <execinfo.h> #include <unistd.h> #include <elf.h> #include <stdio.h> #include <string.h> void* entry_point = NULL; void* base_addr = NULL; extern

When we run an executable, do all the sections get loaded into memory at once?

此生再无相见时 提交于 2021-02-04 20:48:53
问题 So an executable contains of different sections and headers. At the ELF Header we can see some metadata about them like the size of different headers, Starting point etc. Are the different parts of an executable get loaded into memory all at once? If yes, how / when it is defined and where we can see the information about that because the ELF Header doesn't seem to have any parameter in that matter. Thanks in advance. 回答1: With ELF binaries, sections are not what decides how the binary is

Linux Kernel Module Cheat - Qemu Baremetal Xilinx Zynq A9

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 20:00:38
问题 My goal is to emulate the ARM A9 processor as found on the Zynq-7000, running baremetal software. I have tried 2 different approaches to this and run into road blocks on both. Any suggestions on how to proceed would be appreciated. Current answers on StackOverflow: How to make bare metal ARM programs and run them on QEMU? which links to Linux Kernel Module Cheat (LKMC, using v3.0) built using ./build --arch arm qemu-baremetal The examples on the site of using the ARM virtual machine ( -virt

modify build-id in the notes section of the elf file

跟風遠走 提交于 2021-01-29 13:49:31
问题 I need to modify a build-id in the notes section of the ELF file. I see there are plenty of tools to read elf but not to modify them. I found elfedit but it doesn't seem to do what I need. Is it even possible? Here is the output of readelf $ readelf -n myelffile Displaying notes found in: .note.ABI-tag Owner Data size Description GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag) OS: Linux, ABI: 3.14.0 Displaying notes found in: .note.gnu.build-id Owner Data size Description GNU 0x00000014 NT

Define new code section in assembly code to compile ELF binary

 ̄綄美尐妖づ 提交于 2021-01-28 08:06:41
问题 I defined a new code section in my assembly program, which is going to be compiled into 32-bit ELF binary, on x86. I use the linker scripts to assign a specified address for this new code section, it works. However, I noticed that this new section does not be loaded to the memory, after some debugging! I use readelf and figure out that there is no "execution" privilege of this new section: [15] .trampoline PROGBITS 080483d0 004020 000117 00 0 0 16 Then I did this: objcopy --set-section-flags

Retrieving Offsets, Strings and Virtual Address in .rodata and .rodata1

雨燕双飞 提交于 2021-01-28 03:59:55
问题 I am trying to get offsets/virtual addresses, strings in .rodata and .rodata1 sections. For example: #include <cstdio> void myprintf(const char* ptr) { printf("%p\n", ptr); } int main() { myprintf("hello world"); myprintf("\0\0"); myprintf("ab\0cde"); } Above program has .rodata per readelf -a 's output: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [16] .rodata PROGBITS 0000000000400600 00000600 And readelf -W -p .rodata gives me the offsets and the

How to rename dynamic symbols in arm elf .so file?

删除回忆录丶 提交于 2021-01-16 12:10:38
问题 I need to modify a so inside an Android APK. The task is to rename the dynamic symbols in side the so (which is the function name). For example, change from Java_com_example_abc_.... to Java_com_yahoo_zzz_.... I try to use WinHex directly search and replace text words, the apk startup error. Seems like the .hash section also needs to be updated, but i do not know how to update the .hash section. My question is what is the correct or preferable way to rename the dynamic Symbol? I heave been

How to rename dynamic symbols in arm elf .so file?

冷暖自知 提交于 2021-01-16 12:10:37
问题 I need to modify a so inside an Android APK. The task is to rename the dynamic symbols in side the so (which is the function name). For example, change from Java_com_example_abc_.... to Java_com_yahoo_zzz_.... I try to use WinHex directly search and replace text words, the apk startup error. Seems like the .hash section also needs to be updated, but i do not know how to update the .hash section. My question is what is the correct or preferable way to rename the dynamic Symbol? I heave been

How to rename dynamic symbols in arm elf .so file?

独自空忆成欢 提交于 2021-01-16 12:07:38
问题 I need to modify a so inside an Android APK. The task is to rename the dynamic symbols in side the so (which is the function name). For example, change from Java_com_example_abc_.... to Java_com_yahoo_zzz_.... I try to use WinHex directly search and replace text words, the apk startup error. Seems like the .hash section also needs to be updated, but i do not know how to update the .hash section. My question is what is the correct or preferable way to rename the dynamic Symbol? I heave been

How to rename dynamic symbols in arm elf .so file?

你。 提交于 2021-01-16 12:07:02
问题 I need to modify a so inside an Android APK. The task is to rename the dynamic symbols in side the so (which is the function name). For example, change from Java_com_example_abc_.... to Java_com_yahoo_zzz_.... I try to use WinHex directly search and replace text words, the apk startup error. Seems like the .hash section also needs to be updated, but i do not know how to update the .hash section. My question is what is the correct or preferable way to rename the dynamic Symbol? I heave been