elf

Library to read ELF file DWARF debug information

只愿长相守 提交于 2019-11-27 20:36:12
Any recommendations for a good cross-platform library for reading ELF file debug information in DWARF format? I'd like to read the DWARF debug info in a Python program. There's a new kid on the block - pyelftools - a pure Python library for parsing the ELF and DWARF formats. Give it a try. It aims to be feature-complete and is currently in active development, so any problems should be handled quickly and enthusiastically :-) Martin v. Löwis The concept of "ELF debug info" doesn't really exist: the ELF specification leaves the content of the .debug section deliberately unspecified. Common debug

which part of ELF file must be loaded into the memory?

佐手、 提交于 2019-11-27 20:24:06
问题 An ELF file for executables has a program (segment) header and a section header, which can be seen through readelf -a , here is an example: The two pictures above are section header and program (segment) header, respectively. It can be seen that a segment header is composed of several section headers, which is used for loading program into the memory. Is it only necessary for .text, .rodata, .data, .bss sections to be loaded into the memory? Are all of the other sections in the segment (e.g.

bcrypt invalid elf header when running node app

冷暖自知 提交于 2019-11-27 19:34:13
I'm working on a nodejs project for school. I wasn't able to install bcrypt with npm so i installed bcrypt-nodejs and the project worked fine yesterday. But today, when I do a "node app" i have this error : /.../node_modules/bcrypt/node_modules/bindings/bindings.js:79 throw e ^ Error: /.../node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at bindings (/.../node_modules/bcrypt/node_modules/bindings/bindings.js:74:15) at Object.

Extract global variables from a.out file

守給你的承諾、 提交于 2019-11-27 18:09:33
问题 Edit (updated question) I have a simple C program: // it is not important to know what the code does you may skip the code main.c #include <bsp.h> unsigned int AppCtr; unsigned char AppFlag; int SOME_LARGE_VARIABLE; static void AppTest (void); void main (void) { AppCtr = 0; AppFlag = 0; AppTest(); } static void Foo(void){ SOME_LARGE_VARIABLE=15; } static void AppTest (void) { unsigned int i; i = 0; while (i < 200000) { i++; } BSP_Test(); SOME_LARGE_VARIABLE=3; Foo(); } bsp.c extern int SOME

Do .bss section zero initialized variables occupy space in elf file?

孤人 提交于 2019-11-27 17:12:55
If I understand correctly, the .bss section in ELF files is used to allocate space for zero-initialized variables. Our tool chain produces ELF files, hence my question: does the .bss section actually have to contain all those zeroes? It seems such an awful waste of spaces that when, say, I allocate a global ten megabyte array, it results in ten megabytes of zeroes in the ELF file. What am I seeing wrong here? Has been some time since i worked with ELF. But i think i still remember this stuff. No, it does not physically contain those zeros. If you look into an ELF file program header, then you

distinguish shared objects from position independent executables

百般思念 提交于 2019-11-27 16:36:10
问题 I'm looking for a fast way to check if a ELF binary is a shared object or a position independent executable. I think a can do that by checking the contained symbols / functions. I'm looking for a more efficient way of not having to read the complete file. I have to perform the check on different platforms, at least Android, Linux (32 and 64 bit). 回答1: I'm looking for a fast way to check if a ELF binary is a shared object or a position independend executable. There is no way to check: a PIE

How to get the size of a C function from inside a C program or with inline assembly?

醉酒当歌 提交于 2019-11-27 14:29:42
Suppose I have a function like below: # cat 003.c int foo(int a, int b) { return a+b; } And compile it like this: gcc -S 003.c The gets the following assembly result: .file "003.c" .text .globl foo .type foo, @function foo: .LFB2: pushq %rbp .LCFI0: movq %rsp, %rbp .LCFI1: movl %edi, -4(%rbp) movl %esi, -8(%rbp) movl -8(%rbp), %edx movl -4(%rbp), %eax addl %edx, %eax leave ret .LFE2: .size foo, .-foo /* size of the function foo, how to get it?*/ The last line above do get the size of the function. Where does the compiler store the size? Can I get the function's size in some way in my origin C

Segmentation Fault With Char Array and Pointer in C on Linux

对着背影说爱祢 提交于 2019-11-27 14:03:32
So I have the following program: int main(){ char* one = "computer"; char two[] = "another"; two[1]='b'; one[1]='b'; return 0; } It segfaults on the line "one[1]='b'" which makes sense because the memory that the pointer "one" points to must be in read only memory. However, the question is why doesn't the line "two[1]='b'" segfault? Looking at the assembly output from gcc: .file "one.c" .section .rodata .LC0: .string "computer" .LC1: .string "another" .text .globl main .type main, @function main: We see that both strings are in the rodata section so they are readonly. So then how come the line

What does exactly the warning mean about hidden symbol being referenced by DSO?

你说的曾经没有我的故事 提交于 2019-11-27 13:53:46
I have a problem linking some shared library with g++. It gives me a warning like: hidden symbol XXX in YYY is referenced by DSO /usr/lib/... I've read some related questions about particular problems, but I want to understand it in a whole - what does this warning mean and what is a cause: What is DSO? What is a hidden symbol? How can it be referenced, if it's hidden? What is a DSO? A DSO is a Dynamic Shared Object , or less formally a shared library . What is a hidden symbol? A hidden symbol is a symbol (i.e. name of function or data object) that has been compiled with hidden linkage , e.g.

Why is the ELF entry point 0x8048000 not changeable with the “ld -e” option?

吃可爱长大的小学妹 提交于 2019-11-27 12:02:30
问题 Following up Why is the ELF execution entry point virtual address of the form 0x80xxxxx and not zero 0x0? and Why do virtual memory addresses for linux binaries start at 0x8048000?, why cannot I make ld use a different entry point than the default with ld -e ? If I do so, I either get a segmentation fault with return code 139, even for addresses close by the default entry point. Why? EDIT: I will make the question more specific: .text .globl _start _start: movl $0x4,%eax # eax = code for