Questions tagged [relocation]

Relocation is the adaptation of a piece of code assembled on a certain address in memory to another address It is a typical task of dynamic linkers and program loaders, and thus last step in a standard development toolchain.

Relocation is the adaptation of a piece of code assembled on a certain address in memory to another address. It is a typical task of dynamic linkers and program loaders, and thus last step in a standard development toolchain. (typically make - preprocessor - compiler - assembler - archiver - linker - loader)

Relocations can be symbolic or by just adding the base load address of the module (binary/library), the latter is often called a fixup. The object code of some executable formats is assembled to start at 0, making the normal linking process have some relocation aspects also.

The standard book about this subject is "Linkers and Loaders" by John R. Levine.

247 questions
3
votes
0 answers

Using Linker Symbol from C++ code as a fixed constant (NOT relocated) in a shared library (DLL)

Sorry if the title is not very clear. I am using MinGW with GCC 6.3.0 to build a x86 32-bit DLL on Windows (so far). I'll spare you the details why I need hacky offsets amongst its sections accessible from code, so please do not ask if it's useful…
kktsuri
  • 333
  • 2
  • 11
3
votes
1 answer

Using .reloc from assembly

This is a cut-down version of the problem I'm facing on AArch64: I've this macro that keeps dumping some data into a section. #define GEN_DATA(_type) \ .pushsection .mydata_##_type, "aw"; \ .ifndef start; \ start:; \ .endif; \ …
Jeenu
  • 2,109
  • 2
  • 20
  • 27
3
votes
3 answers

What is meant by statically relocated or static relocation of a segment

The elf format executable contains various segments like code, data, bss, stack etc. If we say that the segment xyz is statically relocated what does that mean? The elf format binary contains relative addresses for each segment. When we say…
Ashish
  • 569
  • 3
  • 10
  • 18
3
votes
2 answers

Xtensa --- dangerous relocation: windowed long call crosses 1GB boundary

I got the following error during compilation (.sram.text+0x1283): dangerous relocation: windowed longcall crosses 1GB boundary; return may fail: (UND+0xdeadcafe) in one of the functions. The architecture is Xtensa and the toolchain used is a GNU…
3
votes
3 answers

How does GDB know where an executable has been relocated?

I know modern OSs such as Linux don't always execute an application at the same address it was originally linked. When a debugger starts looking around though, it needs to know the relationship between the original link address and the final…
Elros
  • 313
  • 1
  • 3
  • 10
3
votes
1 answer

Migrating a website to a new domain, and associated google index problem

We currently have a website at "somedomain.net/codefest". We do not own this server (or this domain name). Due to capacity problems, we are now moving to a new server. Since we do not own the old domain name, we are also moving to a new domain…
jrharshath
  • 25,975
  • 33
  • 97
  • 127
3
votes
1 answer

AVR: Relocation truncated to fit

I'm new to this community, in that I've never before created an account and asked a question, but I use this site all the time to solve my programming woes. So thank you! This time, though, I could not find another question matching my exact needs.…
kofdog
  • 91
  • 1
  • 6
3
votes
2 answers

Finding where relocations originate

Using Ulrich Drepper's relinfo.pl script, one can easily count the number of relocations of a DSO, but it doesn't work on .o files. Say I have a large shared library and I'm not happy about the number of its relocations. is there a way to find out…
Marc Mutz - mmutz
  • 24,485
  • 12
  • 80
  • 90
3
votes
5 answers

What is ActivePerl doing when it "relocates" files during installation?

Given some unix program which I've compiled, what might I need to do to relocate it to a different directory and have it continue running correctly. I'm thinking of Perl, but would be interested in other systems like Apache which also seem to fail…
Matt Sheppard
  • 116,545
  • 46
  • 111
  • 131
3
votes
1 answer

ELF Relocation reverse engineering

I am hoping you guys could help me understand how relocation entries and ELF section data are related, and how it is all processed and generated. I have an ancient unsupported tool that takes an ELF file and a related PLF file (partially linked…
thehelix
  • 578
  • 1
  • 6
  • 10
2
votes
2 answers

Is there a way to change the preferred base address of a dll once it's compiled?

I'd like to modify the base address of a few compiled dlls I'm using to move them out of the middle of the virtual space and help with big allocations. Anybody knows of a tool to do that? If it's doable in the loader it seems it would be possible do…
Atom
2
votes
1 answer

What's the difference between R_386_PC32 and R_X86_64_PC32 in link(GNU ld) relocation process

When reading the book Computer System: A Programmer's Perspective Section 7.7.1 Relocation Entries: the brief content of this section is how a linker relocate reference in a different object file. When compile and objdump the example source…
zqlu
  • 23
  • 3
2
votes
1 answer

Why is a RIP-relative LEA instruction producing a PIC-incompatible R_X86_64_32S relocation?

I'm going through the x86-64 tutorial on exercism.org. I'm using NASM on Linux, producing an ELF binary. There is just a bit of C code that invokes my assembly code in a test harness. Their build system specifies -pie in the LDFLAGS and -fPIE in the…
Hut8
  • 6,080
  • 4
  • 42
  • 59
2
votes
1 answer

Why nm hides .rela.eh_frame and .rela.text in .o files?

I'm trying to recreate the behaviour of the command nm in C, and although I was successful getting the names of the symbols and sections, I find out that some extra names appear in my version. $> ./my_nm -a obj.o 0000000000000000 b…
Glitch
  • 155
  • 1
  • 9
2
votes
1 answer

Why function that refers to a global function in the same section can only be solved at link time while local functions will be solve at compile time?

I have this assembly file prog.S : .text #------------------------------main---------------------------------- .globl main .type main,@function main: pushl %ebp movl %esp, %ebp call myGlobalFunction # call to my global func call…
Dewo
  • 23
  • 4