elf

3.1.2-arm-linux-ld选项

浪尽此生 提交于 2019-12-04 02:39:23
有文件link.S,内容如下 .text .global _start _start: b step1 step1: ldr pc, =step2 step2: b step2 经过如下命令编译    arm-linux-gcc -o -c link.S link.o 生成link.o文件    arm-linux-ld -Ttext 0x30000000 link.o -o link_elf_0x30000000    arm-linux-objdump -D link_elf_0x30000000 > link_elf_0x30000000.dis 为什么在最后的机器码列, 有一个跟地址相同的? 0x30000008 在链接时通过 -Ttext指定的代码段地址0x30000000是否就是代码的运行地址? 来源: https://www.cnblogs.com/cheyihaosky/p/11828704.html

Flags in objdump output of object file

余生颓废 提交于 2019-12-04 01:38:33
There is this output of objdump on some object file: $ objdump -h main.o main.o: file format elf32-i386 Sections: Idx Name Size VMA LMA File off Algn 0 .text 0000000b 00000000 00000000 00000034 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .data 00000000 00000000 00000000 00000040 2**2 CONTENTS, ALLOC, LOAD, DATA 2 .bss 00000000 00000000 00000000 00000040 2**2 ALLOC 3 .note.GNU-stack 00000000 00000000 00000000 00000040 2**0 CONTENTS, READONLY, CODE What do these flags CONTENTS, ALLOC, LOAD and so on mean? What you see is the interpretation of the combination of ELF segment flags, section type

What are the real ELF TLS ABI requirements for each cpu arch?

时间秒杀一切 提交于 2019-12-04 00:46:20
问题 Ulrich Drepper's paper on thread-local storage outlines the TLS ABI for several different cpu architectures, but I'm finding it insufficient as a basis for implementing TLS for two reasons: It omits a number of important archs like ARM, MIPS, etc. (while including a bunch of completely-irrelevant ones like Itanium) More importantly, it mixes a lot of implementation details with ABI, so that it's hard to tell which properties are required for interoperability, and which are just aspects of his

Where is the “Section to segment mapping” stored in ELF files?

二次信任 提交于 2019-12-04 00:09:52
问题 As part of trying to write a compiler completely from scratch, I'm currently working on the part the handles ELF files. After skimming through several articles and specifications about them, I still don't quite understand where section to segment mappings are stored. When observing small executables generated by NASM+ld, I can see that the .text section is somehow mapped onto a LOAD-type program header, but how? A small piece of readelf's output when given a small (working) executable as

Linux: update embedded resource from executable

不打扰是莪最后的温柔 提交于 2019-12-03 21:39:00
I have an executable in which I embed a binary file resource using the objcopy method objcopy --input binary --output elf32-i386 --binary-architecture i386 data.txt data.o link to data.o and use extern char _binary_data_txt_start extern char _binary_data_txt_end Is it possible now to update this data inside the executable? The updated data can have the same exact size, I just need to change some of the bits. In windows PE files this is very simple to do using UpdateResource() Nothing special and nothing hard at all. I'll give you correct sequence below, but first let me to correct slightly

.so injection under linux: how to locate address of dlopen()?

自闭症网瘾萝莉.ら 提交于 2019-12-03 20:26:35
Recently I have become interested in Linux, and am trying to create a program which is capable of injecting a shared object (i.e. .so file, 'dynamically loadable library', "DLL" under Windows.) I know this can be done by setting an environmental variable, but I want to do it on a process which is already running. I already know how to do this under Windows. There are several ways, but generally speaking you can just call LoadLibrary() by creating a remote thread using CreateRemoteThread(). Of course you need the address of LoadLibrary in the remote process, but (in my experience) it is always

Accessing data appended to an ELF binary

穿精又带淫゛_ 提交于 2019-12-03 16:52:12
I have a static ELF binary which reads data from a zipfile. In order to simplify distribution, I want to append the zipfile to the binary, like so: $ cat mydata.zip >> mybinary I know that doing so won't damage mybinary, but I don't know how to access the contents of mydata.zip having done so. Is it possible? If so, how? In the past, I've used the trick of appending the data then appending the length of the data, so that all I have to do is open the binary, read the last int of the stream, rewind that length then start unzipping, but that won't work here for various reasons (for instance, I

How to load a shared library without loading its dependencies?

耗尽温柔 提交于 2019-12-03 16:24:48
问题 Say I have a library libfoo.so.1 , which depends (according to ldd ) on libbar.so.1 . However, libbar.so.1 is not available at the moment. My app needs to call a function in libfoo.so.1 which doesn't require libbar.so.1 at all. Is there a way to load libfoo.so.1 , resolve the function symbol and then call it without having libbar.so.1 to satisfy the dependency? It's a case of "I know what I'm doing, just let me do it already". I tried the RTLD_LAZY flag, but it still tries to load the libbar

How can I find the dynamic libraries required by an ELF Binary in C++?

本小妞迷上赌 提交于 2019-12-03 14:35:33
How can I get a list of all the dynamic libraries that is required by an elf binary in linux using C++? Once I've managed to extract the information (filename?) from the binary I can find the actual file by searching through the PATH , but I haven't been able to find any information regarding extracting unmangled information from the ELF binary. Thoughts? The list of required shared objects is stored in the so-called dynamic section of the executable. The rough algorithm of getting the necessary info would be something like this: Parse the ELF header , check that the file is a dynamic

Edit variable values in ELF file?

左心房为你撑大大i 提交于 2019-12-03 13:44:25
问题 I need to change a couple of variables in a compiled ELF file. Trying to explain this clearly I'll use a simple C struct as an example. The single source file is compiled and linked (@ 0x1000) into MyFile.elf from MyFile.c: typedef struct { uint32_t SerialNumber; /* Increments for every time it's programmed */ uint32_t PartNumber; /* Always the same */ char ProdDateTime[32]; /* "YYYY-MM-DD HH:MM:SS" date/time when programmed */ uint32_t CalcCrc32; /* Checksum of the above data */ } MyData_T;