elf

How do you extract only the contents of an ELF section.

I've tried the following, but the resulting file is still an ELF and not purely the section content. $ objcopy --only-section=<name> <infile> <outfile> I just want the contents of the section. Is there any utility that can do this? Any ideas? ...

Global initialized variables declared as "const" go to text segment, while those declared "Static" go to data segment. Why?

#include <stdio.h> const int str[1000] = {0}; int main(void) { printf("arr is %d\n", str[0]); return 0; } Has the following output: [-exercises/adam/stack2]:size a.out text data bss dec hex filename 5133 272 24 5429 1535 a.out Whereas: #include <stdio.h> static int str[1000] = {0}; in...

what's the ELF object file size limitation on 64bit platform?

Assume the x86 64 and linux platform. If you look into the ELF header, the offset are all 64bit. So it's easy to create an object file larger than 4G with relocatoin R_X86_64_64. This means a static .o file and executable can be as large as 64bit can represent. However, for shared library, like gcc , we only have R_X86_64_PLT32 reloca...

Patching code/symbols into a dynamic-linked ELF binary

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...