这是我得到的一些信息program_invocation_name
:
<.bss>
or中<.data>
。stack
内存区域中。这很奇怪......)这是调试器视图program_invocation_name
:
pwndbg> x/s program_invocation_name
0xbffff302: "/tmp/my_program"
Run Code Online (Sandbox Code Playgroud)
问题)
我从程序开始到结束都遵循执行流程,但我找不到设置的那一刻。program_invocation_name
问题)
Q1 . 谁(什么函数)设置了这个值?(loader
设置这个值..?)
Q2。global variable
尽管该值位于 ? 中,但程序如何知道将其识别为stack
?
Q3 . 有时,某些二进制文件运行时没有此值。在这种情况下,问题是loader
?
从这个维基:
它指出偏移量 7 处的数字标识目标操作系统。
我已经为 linux 机器编译了 ac 程序并检查elf header
了结果文件的(前 64 个字节):
> xxd -l 64 helloworld
00000000: 7f45 4c46 0201 0100 0000 0000 0000 0000 .ELF............
00000010: 0300 3e00 0100 0000 8012 0000 0000 0000 ..>.............
00000020: 4000 0000 0000 0000 183f 0000 0000 0000 @........?......
00000030: 0000 0000 4000 3800 0d00 4000 1f00 1e00 ....@.8...@.....
Run Code Online (Sandbox Code Playgroud)
为什么我得到01
第 7 个字节?不应该03
吗?
我是汇编新手,从我了解到的情况.code
与 相同.text
,但下面的代码将使用.code
.
segment .data
msg db "hello, world", 0xa
len equ $ - msg
section .text
global _start
_start:
mov edx, len
mov ecx, msg
mov ebx, 1
mov eax, 4
int 0x80
mov ebx, 0
mov eax, 1
int 0x80
Run Code Online (Sandbox Code Playgroud)
nasm -f elf64 -o hello.o hello.s
ld -s -o hello hello.o
hello, world
sed -i s/.text/.code/ ./hello.s
nasm -f elf64 -o hello.o hello.s
ld -s -o hello hello.o
./stack.sh: line 8: 4621 Segmentation …
Run Code Online (Sandbox Code Playgroud) 我一直在使用 NASM 编写 ELF 二进制文件,并创建了一个打开只读标志的段。运行程序会导致段错误。我在 replit 中测试了该程序,它运行得很好,所以有什么问题?我在 .rodata 部分创建了一个带有 hello world 字符串的常规 NASM hello world 程序,并且运行良好。我用 readelf 检查了二进制文件以确保字符串在只读段中。
我想出的唯一解决方案是在 Rodata 段中设置可执行标志,以便它具有读取/执行权限,但这很糟糕,我希望 Rodata 段是只读的。
这是 ELF-64 hello world 的代码。
; hello.asm
[bits 64]
[org 0x400000]
fileHeader:
db 0x7F, "ELF"
db 2 ; ELF-64
db 1 ; little endian
db 1 ; ELF version
db 0 ; System V ABI
db 0 ; ABI version
db 0, 0, 0, 0, 0, 0, 0 ; unused
dw 2 ; executable object file
dw …
Run Code Online (Sandbox Code Playgroud) 以下 Rust 代码,在 x86_64 平台编译。
#[macro_use]
extern crate lazy_static;
use std::collections::HashMap;
lazy_static! {
static ref HASHMAP: HashMap<u32, &'static str> = {
let mut m = HashMap::new();
m.insert(0, "foo");
m.insert(1, "bar");
m.insert(2, "baz");
m
};
}
fn main() {
// First access to `HASHMAP` initializes it
println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap());
// Any further access to `HASHMAP` just returns the computed value
println!("The entry for `1` is \"{}\".", HASHMAP.get(&1).unwrap());
}
Run Code Online (Sandbox Code Playgroud)
我使用readelf命令查看符号表中HASHMAP变量的大小:
readelf -sW target/debug/deps/section_test-4d7d6a03c56fdde3.o
Symbol table '.symtab' contains 590 …
Run Code Online (Sandbox Code Playgroud) 我是 Linux 新手。我正在尝试将我的 c 程序编译成一个 elf 文件,以便我可以使用 read elf 来查找有关该函数等的信息。每当我尝试将 readelf 与输出文件一起使用时(在编译我的 c 程序之后),它说它不是一个 elf 文件。那么我如何编译我的 C 程序以便它编译成一个 elf 文件。或者我不明白?我正在使用 gcc 进行编译
这是我用于编译的命令行:
gcc -Wall main.c a.out
Run Code Online (Sandbox Code Playgroud)
然后 readelf -aa
好的,所以我用 gcc -o test -Wall main.c 编译它,它编译没有错误,然后用: readelf -a test 做了 readelf ,它仍然说它不是一个精灵,当我做文件时它会出现:PE32+ 可执行文件(控制台)x86-64,适用于 MS Windows,这是怎么回事?
我有一个名为“Fyserver”的可执行linux 文件。我想用这个参数打开它
./Fyserver --pass 2849
Run Code Online (Sandbox Code Playgroud)
如果我不--pass
向 ELF 输入这个参数,那么它应该甚至不运行就退出。有没有办法做到这一点?
注意:我没有这个 ELF 的源代码。我想在 bash 中做到这一点。