Questions tagged [elf]
ELF stands for Executable and Linkable Format, a file format for files containing machine code. Use this tag for questions about the ELF format itself, or for questions which are specifically about reading/writing ELF files.
2,264
questions
0
votes
2
answers
58
views
how do i know A compiler basic datatype how large they are?
i was using arm-none-eabi-readelf -h test.o analizes a object file,it give me
Size of this header: 52 (bytes)
Entry point address: 0x0
i go to the souce code of the arm-...
-3
votes
0
answers
11
views
How to parse the data type of global variables in an elf file? [closed]
I need to parse global variables' data type, I find many docs but have no progress. NEED HELP!!!
use objdump -s and pyelftools(https://github.com/eliben/pyelftools), but type data can't be found in ...
-1
votes
0
answers
11
views
find the address of line number with objdump
I try to find the address memory of specific line number from source code.
I used with: objdump --dwarf=decodedline <file_name>
but I got the output:
checkAddress: file format elf64-x86-64
...
0
votes
0
answers
6
views
How to implement -z separate-code with linker script?
The system ld.bfd linker supports options such as -z separate-code and -z noseparate-code.
With -z separate-code, there are 4 LOAD segments, and its layout is R RE R RW.
With -z noseparate-code, ...
3
votes
1
answer
32
views
Can functions/symbols in the same assembly file be re-ordered to different virtual addresses when linked?
I have some code written in assembly which I need to copy at runtime (code that copies is written in C), hence I need to get the size of the function. I've written the function this way in assembly:
....
0
votes
1
answer
28
views
How to set a value at specified address in an elf file
I have a project for a cortex M4 microcontroller, which compiles and runs fine.
I'd like to add the checksum of the file to the file itself, so I can check the correctness of the binary at runtime.
...
1
vote
2
answers
32
views
Place in ELF to write foreign data
I'm trying to create a program that is monitoring its own checksum. For this purpose I'm trying to find a place where I can put checksum inside the binary. After checking the layout and examining some ...
1
vote
0
answers
17
views
How can I convert a Qualcomm firehose file from bin to elf, in order to load it in QFIL?
I have a Oneplus 7T HD1907 stuck in recovery mode.
I wanna use this guide to copy the userdata partition to my computer, before I proceed with factory resetting the phone.
I used Firehose Finder to ...
0
votes
0
answers
34
views
Newly appeared symbols in ELF file when migrating from gcc 10 to gcc 12
I am comparing two elf files produced from the same exact c++ code base but different gcc/g++ versions : 10.2 and 12.2. Both are compiled using the arm-none-eabi flavor of gcc/g++ for an STM32 CPU.
I ...
0
votes
1
answer
43
views
How to add machine code at the end of an executable file on Windows(PE) or Linux(ELF)?
Detail
I know that it is possible to add code in the famous 'code caves', but they are limited in terms of space, so I would like to add codes in this file without using these spaces, and for that I ...
-1
votes
1
answer
27
views
Which segment of the ELF file should the static int variable be loaded into?
I met a question when I tried to finish my operating system lab.
I was asked to write an MBR Bootloader program and I have already finish it, but there's a comment in the frame code saying that "...
0
votes
0
answers
11
views
Wrong section LMA address when using LD file
I need to load the data sections in different address from VMA.
so I defined 2 typed of memory and updated the LD file,
for example bss section:
.bss : ALIGN(0x20) {
PROVIDE(__bss_start = ...
0
votes
0
answers
53
views
Override fvisibility in Fortran routine
In a shared object, I can make my Fortran routines unavailable from outside using -fvisibility=hidden.
In C/C++ you can override this setting in your routines by void __attribute__ ((visibility("...
0
votes
0
answers
20
views
Can a statically linked Linux lib be converted to COFF and be linked by MinGW, to run on a Linux system?
There is a windows application that I have the source to. It compiles under MinGW, links fine against wine, and executes, on a Linux system.
However, I would like it to call into a Linux library.
...
1
vote
0
answers
66
views
Why did my binaries grow after toolchain change? [closed]
I'm updating buildroot in one of our company's powerpc-based products.
Previously used toolchain was an in-house built gcc-4.9, I've switched to Bootlin powerpc-e300c3 glibc stable 2021.11-1 (as ...
3
votes
1
answer
56
views
`mprotect`ing a custom ELF section leads to segmentation fault
I have come across this interesting StackOverflow post: How do you get the start and end addresses of a custom ELF section?
and I thought whether it might be possible to apply mprotect() to the ...
0
votes
0
answers
22
views
ELF replace WSL-path to Windows-Path (GCC / ARM / CortexM)
If you build a cortexM firmware on linux (WSL in this case), the resulting *.elf file for debugging will carry "nix" paths, example:
/home/user/project/
/home/user/project/Src/main.c
/home/...
0
votes
1
answer
38
views
Understanding ELF file build ID
Im comparing two binary files generated by versions of same code that could or could not be equal. Meld showed a small difference between the binaries, but completely disassembling both binaries ...
0
votes
0
answers
19
views
Reverse analysis of an Elf file
question:
CrackMe1 is an ELF executable that can be executed independently in Android.
Execute CrackMe1 program in shell and prompt "Input Your Answer"
Input the correct string, press enter, ...
3
votes
0
answers
84
views
prevent arm64 gcc from generating GOT entries for symbols that reside in other object files
When compiling a executable on x64, gcc won't generate GOT entries for symbols that are present in other object files, e.g.:
// 1.c
extern void (*const target)(char *c);
int main() {
target("...
0
votes
1
answer
436
views
cannot execute binary file: Exec format error for a binary compiled in WSL environment
I have recently started working on WSL environment.
I have compiled one program in WSL environment which is of type "ELF 64-bit LSB shared object" but when I try to run it in the same ...
0
votes
1
answer
30
views
Global Offset Table: "Pointers to Pointers"? Is this handled by the loader?
This question is about Linux (Ubuntu) executables.
I'll detail things as I understand them to make it clearer if anything's off (so please correct me where applicable):
The GOT acts an extra level of ...
1
vote
0
answers
50
views
Get file size in uefi-rs
I am making a basic uefi application that is supposed to load an elf kernel. I have gotten to the point that I have the fille loaded, and a buffer with the file info. But to actually read the file and ...
-1
votes
1
answer
36
views
How linker script files work when generate elf file
I am using linker script file to generate specific elf file.I add this code to lscript.ld
.test : {
*(.text.ssc_entry)
*main.o(.text)
*main.o(.text.*)
} > ...
0
votes
1
answer
46
views
Jump to specific address in loaded shared object file (loaded by the LD_PRELOAD)
Suppose we have two programs. The program test is in binary form (ELF file), and the second program is a shred object file, say f.so.
I want to hook some instruction in the program test and move ...
0
votes
1
answer
43
views
Finding all executable code regions in a process
I'm writing a tool for program analysis. I want to find all code regions (i.e. regions with machine instructions) inside the program. I also want to consider dynamically linked code. This far, I have ...
1
vote
1
answer
150
views
What's the diffrence between __libc_start_main and __libc_start_call_main?
I came to know about the __libc_start_main function. I have been thinking that __libc_start_main call the main function like this, but when I checked ret of main function of my own program, it is the ...
5
votes
0
answers
87
views
ld creates elf segments with wrong permissions
I'm writing a bare-metal aarch64 program (toolchain aarch64-unknown-elf-) which I'm building using the following linker script:
SECTIONS {
.text : {
*(.text*)
}
.rodata ALIGN(...
0
votes
0
answers
72
views
Ida patch program Failed
I tried to create a segment using ida, and when I tried to save it as a new file, it never worked
I created a segment and set all its contents to 0.
Then I do the following:Edit -> Patch Program -&...
0
votes
0
answers
57
views
How to decide if FF instruction is a call instruction or a jmp instruction in X86-64 ELF under linux? [duplicate]
I have such ELF in linux and I disassemble it to do some research. However, I get confused "How to decide if FF instruction is a call instruction or a jmp instruction?
For example, the ff ...
0
votes
1
answer
71
views
How to find out what kind of ELF files a linux system can execute? [closed]
I want to know what kind of ELF executables can my linux system execute without bruteforcing until this error disappears:
Failed to execute process: '<executable>' the file could not be run by ...
0
votes
1
answer
26
views
running NASM assembly gives a segfault
I'm trying to make ELFs from scratch to better understand how they work. I tried this simple program:
mov eax,1
mov ebx,4
syscall
Which should simply exit with code 4, but when I assemble (nasm test....
0
votes
1
answer
76
views
Ldd shows a weird library "do_not_link_against_nvinfer_builder_resource" that doesn't match linker logs
I'm trying to link a new library to my project libnvinfer_builder_resource.so.8.5.1, but I got this error when running it.
bazel-out/host/bin/gen_trt_ops_py_wrappers_cc: error while loading shared ...
0
votes
0
answers
23
views
Why does rpmbuild rewrite elf headers and how do I stop it?
I have a stripped down spec file that looks like:
Name: some-binary
Version: 6.1.0
Release: 1
License: proprietary
Summary: a binary
%description
Whatever
%install
install -d %{buildroot}/fromrpm
cp ...
0
votes
0
answers
37
views
td-agent configuration for postgresql Logs
I have installed the fluentd agent in my VM where postgresql is installed. Now I am looking for the td-agent.conf file which could help me to ship the pg logs and /var/log/messages to kibana. I am ...
1
vote
0
answers
157
views
How to find structure member memory address from dwarf debug information?
I'm trying to find structure member memory address(Non Virtual Memory, embedded) from dwarf.
And there's two things i don't understand.
First, In below dwarf Info1 DW_AT_location value = [3, 192, 63, ...
3
votes
1
answer
104
views
Why does a elf file have so many unsused/wasted space
I've been looking at loading a elf file into the memory, but in the process, I've found out that there is huge chunk of unused space in the file.
This is the elf file i got https://cyao.page/kernel....
0
votes
0
answers
45
views
Normal for gdb coredumps to label symbol with incorrect function name when dynamic libraries stripped?
This is the output of me playing around with using 'strip' and various options to try to replicate what I am seeing. Here is a normal backtrace...
#0 0x00007f06ff7e96ad in Numbers::AddOne(int) () ...
0
votes
1
answer
167
views
How do I get a list of shared library base addresses from a core dump in GDB when I don't have the shared library available?
I've got a core dump that came from another machine, but I don't have all the shared libraries that were loaded in the crashed process. I am not able to log on to the machine or reproduce the install ...
-1
votes
1
answer
32
views
Allocating a large array on the stack [C]
perhaps there's already an answer to this, but I couldn't find it.
Suppose I have 2 programs as followed:
Prog.A:
int main (void) {
int big[100];
printf("%lu\n", sizeof(big));
...
1
vote
1
answer
52
views
elf aarch64 golfed with sys_write
To better understand the ELF format and the ARM aarch64, I'm trying to create my elf binary without compilers, just echoing bytes with bash.
Will can see my effort here: http://www.github.com/...
1
vote
1
answer
85
views
Rust & Sentry: Can't get uploaded debug files to match on reported events
I'm using Yocto to build Rust normally on an embedded device with stripped binaries.
But we could never get the "uploaded" debug information feature to work. It only ever works when the ...
1
vote
1
answer
85
views
How to debug the ELF loading process on Linux (Fedora)?
What are some effective approaches to debug the actual process of loading an ELF binary on a Linux system? I am on Fedora 36 and have created an ELF file. However, when I try to run the ELF file from ...
0
votes
1
answer
113
views
How can I map an address range to the ram with Qemu?
I'm trying to run an elf image for an embedded system in Qemu. I read that we can pass elf binaries to Qemu with -kernel option and it configures itself to run the code from the entry address ...
0
votes
1
answer
63
views
e_machine field in elf header
In the elf header, there's 'e-machine' field. So my question is does it only specify the processor architecture the file can run on or it specifies the processor architecture that was used to make the ...
0
votes
0
answers
45
views
How can I work around gdb w/gef giving me "No function contains specified address"?
I am debugging a program using gdb with the gef extension. I am using GNU gdb (GDB) Fedora 12.1-1.fc36. The program I am debugging calls setvbuf and as it's dynamically linked, a call instruction ...
0
votes
0
answers
19
views
how to use *abs* section symbol
I generate a .o file based on a bin file, but when I use it .o file symbols, “start” and “end” can be output, but the “size” is always changing (start end suze is in the symbol of the. o file)
#...
0
votes
2
answers
151
views
symbol names are trimmed in elf file to 25 characters
I am compiling a simple c file with gcc on Linux and using readelf to find info of symbols.
The function names (and perhaps other symbols - I didnt check) are trimmed to 25 characters.
Is there a way ...
0
votes
0
answers
36
views
DT_HASH and DT_GNU_HASH produce different values
I am reading the dynamic symbol table .dynsym and checking the DT_HASH and DT_GNU_HASH entries.
Oddly, I found out that the values are different. I know that DT_GNU_HASH can be a bit complicated to ...
0
votes
0
answers
21
views
Is it possible to use any program as a library?
I'm trying to create some debug scripts with compiled programs, for this I'm trying to create something where I prepare my variables in some code I generate and then jump into another program.
Is ...