Why GCC compiled C program needs .eh_frame section?

First of all, the original reason for this was largely political – the people who added DWARF-based unwinding (.eh_frame) wanted it to be a feature that’s always there so it could be used for implementing all kinds of stuff other than just C++ exceptions, including: backtrace() __attribute__((__cleanup__(f))) __builtin_return_address(n), for n>0 pthread_cleanup_push, implemented in terms of … Read more

arm gcc toolchain as arm-elf or arm-none-eabi, what is the difference?

Here is an excellent doc. Tool chains have a loose name convention like arch [-vendor] [-os] – eabi arch – refers to target architecture (which in our case is ARM) vendor – refers to toolchain supplier os – refers to the target operating system eabi – refers to Embedded Application Binary Interface some illustrations as … Read more

What exactly does `-rdynamic` do and when exactly is it needed?

Here is a simple example project to illustrate the use of -rdynamic. bar.c extern void foo(void); void bar(void) { foo(); } main.c #include <dlfcn.h> #include <stdio.h> #include <stdlib.h> void foo(void) { puts(“Hello world”); } int main(void) { void * dlh = dlopen(“./libbar.so”, RTLD_NOW); if (!dlh) { fprintf(stderr, “%s\n”, dlerror()); exit(EXIT_FAILURE); } void (*bar)(void) = dlsym(dlh,”bar”); … Read more

How can I examine contents of a data section of an ELF file on Linux?

objdump -s -j .rodata exefile gives a side-by-side hex/printable ASCII dump of the contents of the rodata section like: Contents of section .rodata: 0000 67452301 efcdab89 67452301 efcdab89 gE#…..gE#….. 0010 64636261 68676665 64636261 68676665 dcbahgfedcbahgfe It doesn’t look like there’s anything in there to control formatting, but it’s a start. You could always undump the … Read more

What’s the difference of section and segment in ELF file format

But what’s difference between section and segment? Exactly what you quoted: the segments contain information needed at runtime, while the sections contain information needed during linking. does a segment contain one or more sections? A segment can contain 0 or more sections. Example: readelf -l /bin/date Elf file type is EXEC (Executable file) Entry point … Read more

C/C++ with GCC: Statically add resource files to executable/library

Update I have grown to prefer the control John Ripley’s assembly .incbin based solution offers and now use a variant on that. I have used objcopy (GNU binutils) to link the binary data from a file foo-data.bin into the data section of the executable: objcopy -B i386 -I binary -O elf32-i386 foo-data.bin foo-data.o This gives … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)