2,439 questions
1
vote
0
answers
12
views
How to diagnose differences between versions of .so file to understand different linker behaviour?
I have a pre-built image of a shared library, and that library implements main() with something like:
int main(...) {
bootstrap(...);
return 0;
}
bootstrap(...) {
/*...*/
sc_main(...);...
0
votes
2
answers
167
views
CPU Mode switches in qemu emulated machine. Undefined behavior. 16 bit code gets executed as 32 bit mode after a far jump
https://github.com/PoutineSyropErable/MapleKernel
The BareBones dir.
debug2 branch.
e5cf6d69e3f9f053 commit hash.
How is a proper 32PM -> 16RM mode switch done on modern x86_64? My 16 bit code is ...
5
votes
1
answer
76
views
write(2) syscall returns EFAULT for string in .rodata on OpenBSD 7.3--7.8
I'm writing a hello-world program in i386 assembly for OpenBSD 7.8. The program works if the string (buf argument of write(2)) is in .data or on the stack, but write(2) returns EFAULT (== 14) if the ...
1
vote
1
answer
106
views
Any reason why the ELF spec allows only one SHT_DYNAMIC section but doesn't forbid several PT_DYNAMIC segments
The ELF manual says that SHT_DYNAMIC sections can only appear once in any given ELF object file.
SHT_DYNAMIC: This section holds information for dynamic linking. An object file may have only one ...
1
vote
0
answers
49
views
Using objdump to produce gas-compatible assembly?
I have an ELF file (more specifically, a 32-bit MIPS-III statically linked one). The code in it starts with something like:
entry:
00100008 28 0c 00 70 clear at
0010000c 28 14 00 70 clear ...
0
votes
1
answer
64
views
Which `RUNPATH` is used by `dlopen()` when called from a shared library loaded by another shared library?
I have the main program prog which links with shared libraries called base and db. The shared library db itself links with base and also with a shared library pluginloader which also links with base ...
3
votes
1
answer
56
views
File offset and virtual address in ELF
From ELF documentation:
Loadable process segments must have congruent values for p_vaddr and p_offset, modulo the page size.
What is the motivation for this rule? Following it generates gaps in ...
3
votes
1
answer
104
views
How to add debug information for NASM functions? From C header file?
I have function foo which is used by inclusion of header and linking with the implementation staticaly:
main.c:
#include <stdio.h>
#include "foo.h"
int main(void) {
printf("%f\...
1
vote
2
answers
126
views
Segments do not respect their own alignment
I noticed that ELF binaries often do not respect their Alignment value for LOAD segments.
The alignment is specified in the program header and man pages describe the p_align value like this:
...
1
vote
1
answer
83
views
runpath with $ORIGIN ignored when program is set user id root
I am trying to run an application that is set user id root on Raspbian :
-rwsr-xr-x 1 root user 508K May 11 13:55 my_app
This application is shipped with a shared library installed in a non ...
2
votes
1
answer
6k
views
Testing library for 16kb page size
As native libraries soon need to support 16KB page size I would like to test existing .so libraries.
According to the Google documentation this can be done using atest:
You can run atest ...
0
votes
1
answer
77
views
ELF map IP to offset in .text section
Given that I know the virtual address of an instruction I and the address at which the .text section containing that instruction was loaded T, how can I find the file offset of that instruction within ...
1
vote
0
answers
50
views
Matching Debug Info to opened Source File
Im working currently on a sideproject that centers around building a kind of "diy debugger" for an embedded controller im working with.
I can not attach debugger directly to it, but im able ...
1
vote
1
answer
121
views
How to write an encryption function for this decryption function (picoCTF GDB Test Drive)?
I'm working on the picoCTF reverse engineering challenge GDB Test Drive, where the goal is to retrieve the encrypted flag using the decryption function inside the binary.
But instead of using GDB, ...
1
vote
3
answers
882
views
Partial vs. full RELRO
I'm trying to understand the difference between partial and full RELRO when compiling ELF files. What I gather from various sources is that only under full RELRO is the entirety of the GOT protected.
...
0
votes
1
answer
75
views
My mmap fails where Linux's ELF loader doesn't
I try to mmap an ELF64 compiler with GCC, but my mappings end up failing when I try to map 0x4a5000:
Mapping attempt: vaddr=0x4a5000, filesz=23416, prot=3, fd=3, offset=675664
Here are the mappings my ...
0
votes
0
answers
199
views
PT_NOTE segment in ELF files has bogus offset/address
I'm looking at a bunch of ELF binaries that have a curious entry in the program header (segment) table:
Type PT_NOTE, p_offset=p_addr=0x254, p_filesz=p_memsz=0x44
The offset points in the middle of ...
0
votes
1
answer
58
views
How to map runtime address from /proc/pid/maps to binary executable?
With a binary executable and a /proc/pid/maps of a process which spawns from it, I want to map a runtime instruction address at this time (can be retrieved by gdb or any debuggers) towards the ...
1
vote
0
answers
37
views
Why is gdb showing wrong source files?
I am build code for a cortex-m0 using arm-none-eabi. My project has lots of functions removed using the -ffunction-sections -fdata-sections -Wl,--gc-sections options. When I start stepping into my ...
0
votes
0
answers
151
views
How do I get u-boot to boot a signed (non-Linux) firmware image on my AM64x?
I have a working system, based on the EVM board for the TI Sitara AM64x.
It is running u-boot 2024.04, compiled from the TI SDK 10 and can boot my ELF file containing my app and threatX OS using the ...
1
vote
0
answers
96
views
Handling the .bss Section in Raw Binary Formats and Freestanding Environments
When working in a raw/freestanding environment, I have a question about the .bss section in ELF files. If I link and set the output format to binary (not ELF), where will the .bss section be in the ...
1
vote
1
answer
58
views
Why GNU `ld` has different output from NASM vs GAS `.o` files using equivalent sources?
While doing some experiments inspired by many interesting articles on tiny ELF executables, I've noticed GNU's ld generates a different executable when fed with a nasm-generated .o object file or with ...
-1
votes
1
answer
146
views
How to update the section in ELF file, using a binary file [closed]
I am using stm32cubeIDE and trying to store crc at the end of binary for update purposes.I am using this method because otherwise the debug will not work and i have to mark the .crc region as NOLOAD ...
6
votes
1
answer
180
views
Is the statement “Uninitialized global variables get weak symbols” in CSAPP accurate?
In Computer Systems: A Programmer’s Perspective (CSAPP), the book mentions that “Uninitialized global variables get weak symbols.” After some experimentation, I found this description seems ...
1
vote
1
answer
132
views
What is the difference of weak and unique symbol binding?
A c++17 inline variable will be compiled to a unique symbol by gcc. If use clang it will be a weak symbol.
I found documentation of symbol binding at Oracle Linker, but there is no unique binding in ...