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
6
votes
1 answer

Is my understanding on the use of the symbol table and relocation table correct?

I'm currently having a hard time understanding the linking/loading concept. Could you tell me if following statements on the use of the symbol and relocation tables are correct? In a relocatable object file, the symbol table must contain entries…
Multisync
  • 767
  • 6
  • 25
5
votes
1 answer

How to distinguish between relocatable and non relocatable symbols inside .data.rel section

I'm trying to create a simple linker for a barebone ARM application. Currently the loader, that loads the module, will simply add the offset to all records inside the .got and .data.rel sections. This works fine in .got, and for all symbols that…
SztupY
  • 10,291
  • 8
  • 64
  • 87
5
votes
1 answer

Calculation of relative offset in small code model

I am trying to understand the RIP relative offset used in small-code model. Perhaps the only approachable resource on the internet on this topic is: https://eli.thegreenplace.net/2012/01/03/understanding-the-x64-code-models But in this post also a…
Ricky
  • 635
  • 2
  • 5
  • 20
5
votes
2 answers

C++ How to control Image Base of LoadLibrary API

After Rebasing the main program very high up in it's own imagebase. How do I guarantee that the dll that gets loaded will load in 0x400000 dllImageBase = LoadLibrary("test.dll"); printf("imagebase = 0x%x", dllImageBase); I always get 0x460000…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
5
votes
1 answer

Who performs runtime relocations?

I'm trying to better understand runtime relocations in Linux, specifically who performs them in different situations. Below is my current understanding, is it accurate? Position-dependent statically-linked executable - no runtime relocations…
uvuv
  • 368
  • 1
  • 7
5
votes
1 answer

What is absolute symbol and how to define it in C?

In the man page of nm. It says “A” The symbol's value is absolute, and will not be changed by further linking. However, I don't know what that means. How can I define a variable or something else to make its value absolute in C? If I declare a…
KenKenKen
  • 467
  • 1
  • 5
  • 18
5
votes
1 answer

Problems with using log4j in the shaded jar

I have the following situation in my project: a large module (call it converter) with its own dependencies is being integrated into the main application (which has been developed separately by different people and has its own, partially…
shekvl
  • 51
  • 1
  • 4
5
votes
3 answers

Recompiling with -fPIC

I have MPICH 3.0.4 installed on my machine (Ubuntu 12.04). I am trying to install a library called Qthreads which I have worked with and successfully installed before (except with the MPICH2 package installed). The configuration works…
Alex Brooks
  • 1,151
  • 1
  • 10
  • 39
4
votes
2 answers

relocation entries in a shared lib

I'm investigating relocation of shared libraries, and ran into something strange. Consider this code: int myglob; int ml_util_func(int p) { return p + 2; } int ml_func2(int a, int b) { int c = ml_util_func(a); return c + b +…
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
4
votes
0 answers

ElasticSearch cluster always auto-balancing

I have an issue with ES auto balancing shards in my cluster: I've seen it moving shards from nodes with more free disk space to nodes with less free disk space It has been moving shards non-stop for days, which I thought was ok until I realized it…
Daniel
  • 21,933
  • 14
  • 72
  • 101
4
votes
2 answers

Why does global symbol in the same file needed to be relocated?

I had a C program for test: a.c int a = 0; static int fa_local() { a = 78; int b; int c; } int fa_global() { a = 7777; fa_local(); } int test() { a = 6666; fa_global(); } This is its relocation table after…
Freeman
  • 61
  • 6
4
votes
1 answer

ELF label address

I have the following code in .s file: pushq $afterjmp nop afterjmp: movl %eax, %edx Its object file has the following: 20: 68 00 00 00 00 pushq $0x0 25: 90 nop 0000000000000026 : 26: 89 c2 …
Ujjwal Rajput
  • 181
  • 2
  • 8
4
votes
1 answer

ARM M3 relocate code -> faults

ARM Cortex M3 (LPC1519) I have written a bootloader (which so far seems to work) which runs in flash and writes the program into the Flash (behind the bootloader). The programm gets written and starts to run properly (at least when debugging). When…
Traummaennlein
  • 474
  • 5
  • 12
4
votes
1 answer

what's the ELF object file size limitation on 64bit platform?

Assume the x86 64 and linux platform. If you look into the ELF header, the offset are all 64bit. So it's easy to create an object file larger than 4G with relocatoin R_X86_64_64. This means a static .o file and executable can be as large as 64bit…
limi
  • 695
  • 1
  • 8
  • 18
4
votes
2 answers

How is it that main function is always loaded at the same address whereas variables have different address most of the time?

I wrote this small program today and I was blown away by the results. Here is the program int main(int argc, char **argv) { int a; printf("\n\tMain is located at: %p and the variable a is located at address: %p",main,&a); return 0; } on my…
user446236
  • 51
  • 1
  • 3
1 2
3
16 17