elf

Get location of symbols in a.out file

限于喜欢 提交于 2019-12-24 20:23:05
问题 This question does a great job explaining how to get the symbols (variables, functions, etc) of an elf file. Now that I have the symbols I will like to know on what location (module) they are . For example if I compile a program that consists of the files main.c , someFile.h and someFile.c . Also let's say that the main.c program contains the global variable int Counter. then how I be able to tell that variable Counter is located in main.c? 回答1: the Answer is in here. . 来源: https:/

How do I best determine if a binary contains STAB or DWARF debug information?

元气小坏坏 提交于 2019-12-24 14:14:51
问题 When it comes to ELF, two accompanying debugging formats are overwhelmingly popular to others, namely STAB and DWARF. I'd like an easy way to ascertain whether a given binary contains debug information of one form or the other, preferably without having to inspect section names (.stab, etc.). What are good ways of accomplishing this? 回答1: When it comes to ELF, two accompanying debugging formats are overwhelmingly popular The STABS format has not been used by default by any current compilers

Reading sh_name from header will return one value everytime

你。 提交于 2019-12-24 11:53:59
问题 Whenever isstatic32 is called, it will return STATIC even though the program is dynamically compiled. I have no idea what to do. I've tried everytime it detects .dynamic from sh_name, it adds 1 to a variable and if the variable is > 1 it will return dynamic, but that didn't work. (won't let me post code here) #include <stdio.h> #include <elf.h> #define DYNAMIC 1 #define STATIC 2 static int isstatic32(FILE* fd, Elf32_Ehdr eh, Elf32_Shdr sh_table[]) { static int i; static int kek = 0; static

How can I link the source path of a compiled library to a different location in Eclipse?

落花浮王杯 提交于 2019-12-24 10:59:19
问题 I've installed the msp430-gcc compiler and associated tools to do some open-source msp430 development at home using Eclipse. I'm developing on a slightly older Macbook Pro running OS X Lion and installed the tools using MacPorts. I'm running Eclipse 3.7.2 with the CDT and GCC Cross Compiler Support plug-ins. I have a simple empty main() written that compiles and links just fine. The ELF parser lets me view the contents of the ELF binary just fine with the exception of one component; when I

understand hexedit of an elf

时光总嘲笑我的痴心妄想 提交于 2019-12-24 08:28:53
问题 Consider the following hexedit display of an ELF file. 00000000 7F 45 4C 46 01 01 01 00 00 00 00 00 .ELF........ 0000000C 00 00 00 00 02 00 03 00 01 00 00 00 ............ 00000018 30 83 04 08 34 00 00 00 50 14 00 00 0...4...P... 00000024 00 00 00 00 34 00 20 00 08 00 28 00 ....4. ...(. 00000030 24 00 21 00 06 00 00 00 34 00 00 00 $.!.....4... 0000003C 34 80 04 08 34 80 04 08 00 01 00 00 4...4....... 00000048 00 01 00 00 05 00 00 00 04 00 00 00 ............ How many section headers does it

How to reduce ELF section padding?

旧时模样 提交于 2019-12-24 07:49:12
问题 I used crosstool-NG to create a PowerPC toolchain with gcc 6.3.0 and glibc 2.25. I have the following test program, test.c: int main() { return 0; } I compiled it with the command: powerpc-unknown-linux-gnu-gcc -s -Os -o test test.c The final binary is 66904 bytes, which is much larger than expected. The section headers look like this: $ powerpc-unknown-linux-gnu-readelf -S test There are 27 section headers, starting at offset 0x10120: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk

Difference between input and output sections in a linkerfile?

为君一笑 提交于 2019-12-24 03:09:38
问题 While it could be clear in the context of a resulting binary or ELF file what is a section, many places in documentation (independently of the compiler used) refers them as to Input or Output sections. What are the differences between these? 回答1: The linker consumes object files (and possibly shared libraries) and outputs an executable or shared library. The input object files are composed of named sections - .text , .data , .rodata , .bss , etc. So is the output file. It is a principal part

programatic way to find ELF aux header (or envp) in shared library code?

眉间皱痕 提交于 2019-12-24 00:01:14
问题 I'm looking for a programatic way to find the powerpc cpu type on Linux. Performing some google searches associated an answer suggesting the mfpvr instruction I found that this is available in the ELF AUX header, and sure enough I can obtain the POWER5 string for the machine I'm running on with the following: #include <stdio.h> #include <elf.h> int main( int argc, char **argv, char **envp ) { /* walk past all env pointers */ while ( *envp++ != NULL ) ; /* and find ELF auxiliary vectors (if

Relative-to-executable path to ld-linux dynamic linker/interpreter

孤街浪徒 提交于 2019-12-23 22:29:07
问题 I want to ship and archive binaries (executables with libraries) which are backward and forward compatible with as many Linux distributions as possible and the whole package relocatable. As I understand system libraries like libc also need to be shipped because the executable will crash given a different version of libc . Meanwhile libc seems to be coupled with ld-linux (e.g. binaries compiled on Debian testing already does not work on Ubuntu 18.04 LTS), so I need to package ld-linux too. My

Loading/unloading ELF sections on demand?

我的未来我决定 提交于 2019-12-23 18:52:01
问题 For a rather obscure use case I'd like to have a (large) statically linked Linux executable made up of a small piece of control code and large pieces of static (read-only) data. Is it possible, to save memory, to get the loader to load only the sections for the control code, and then manually load the sections of RO data as they are needed, and unload them again once the processing is done? Is this possible? (I suppose data streams (on the filesystem level) could be used to solve this, but