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
2
votes
2 answers

How to get GCC to export ALL symbols to the output file

I am developing an operating system, and I need to load some modules BEFORE paging is set up. So since paging is not set up at this point I need to relocate all of the symbols in the program to there physical address. My problem is that not all…
user1454902
  • 750
  • 9
  • 24
2
votes
1 answer

PIC compilation - error: relocation R_X86_64_32S against `vtable for hit' can not be used when making a shared object; recompile with -fPIC

I'm newbie with Linux and I'm having trouble with compiling a make file which works well in a 32-bit machine. I didn't write this program but I need it to work to use its functionalities. My machine is 64-bit and I get the following message…
Daniel
  • 21
  • 4
2
votes
2 answers

How prevent from dynamic relocation (rela.dyn)?

I am trying to run a simple program on an powerpc embedded system without any operating system. I am using GNU compiler-linker tools and PSIM as simulator. I've written my own very simple Linker Directive file. I've used a global variable in my…
2
votes
1 answer

fPIC code in a static library: Why? What happens?

What happens when Position Independent Code is placed in a static library? (In particular, on x86-64) That is to say: Several .o files are generated with PIC and placed in a .a file. This .a is statically linked into a final executable as…
nonot1
  • 2,788
  • 4
  • 25
  • 41
1
vote
2 answers

What is the goal to contains the information about static variables in the symbols table?

I'm trying to understand .symtab setcion type for the relocatable object files. And I know, that it contains information about static variables. But why? All we need to do for linking relocatable object files with some other is relocate adresess of…
Nelson Tatius
  • 7,693
  • 8
  • 47
  • 70
1
vote
0 answers

Relocation Error when activating Conda environment

In a Unix system, I use mamba activate to activate a Conda environment where Tensorflow 2.11.0, version for GPU, is present. After the environment is activated, if I digit ls or similar commands, I get the following error: relocation error:…
nrosi
  • 11
  • 2
1
vote
1 answer

Accessing global variables in ARM64 position independent assembly code

I'm writing some ARM64 assembly code for macOS, and it needs to access a global variable. I tried to use the solution in this SO answer, and it works fine if I just call the function as is. However, my application needs to patch some instructions of…
swineone
  • 2,296
  • 1
  • 18
  • 32
1
vote
0 answers

Cmake - Relocation error at runtime when running in server

I started with C and C++ a few days ago and I'm losing my mind with this problem. I wrote and compiled a program in C++ using cmake in a Windows Subsystem for Linux (WSL, Ubuntu). The program opens a CSV file, does some filtering and streams out the…
DCD
  • 11
  • 2
1
vote
1 answer

What's the difference between R_386_GOT32 and R_386_GOT32X?

I've found a lot of documentation for R_386_GOT32, but not R_386_GOT32X. I was able to find https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-draft.pdf which shows the calculation for R_386_GOT32X, but it looks to be the same as that for…
BrockLee
  • 931
  • 2
  • 9
  • 24
1
vote
0 answers

Is a non PIE executable guaranteed to be loaded at its base adress?

Unlike shared objects that are loaded into an existing adress space, I suppose that nothing would prevent an executable from gettings its segments loaded at their desired adresses. But is this guaranteed by the OS ?
Aaa Bbb
  • 627
  • 4
  • 12
1
vote
0 answers

RELOCATION ERROR - GLIBC symbol not defined; Manjaro Linux

im a beginner when it comes to Linux trying to run an ASP.Net Core 6 webapp build, but launching it only gives the following error: relocation error: /usr/lib/libc.so.6: symbol _dl_fatal_printf version GLIBC_PRIVATE not defined in file…
leukk
  • 11
  • 1
1
vote
1 answer

Avoiding linking against static libraries when using libtool

I am trying to cross compile ImageMagick on a linux machine. The libstdc++.a that comes with the toolchain is not compiled with fPIC. I would like to use the so file instead. However libtool keeps linking libstdc++.a (as whole-archive) and I get…
l.thee.a
  • 3,231
  • 6
  • 25
  • 28
1
vote
0 answers

Linker/Loader and Relocation

I'm a bit confused with relocation concerning linker and loader. I know that the linker links modules together and that the loader loads them into a place in memory. However if our main program has a subroutine that starts at the same address of the…
1
vote
2 answers

How can I load the absolute address of a symbol larger than 0x7FFFFFFF in RiscV64 assembly

I am writing a kernel and I need to self relocate above 0x7FFFFFFF. To do that, I need to refer, using absolute addressing, to the beginning and end of my kernel and to a symbol, where execution continues after the relocation. I have been unable to…
1
vote
1 answer

Executable Without .RELOC Section

I am using MSVC 2019. I have compiled a simple C++ code (Hello World...). When I compile it in release mode in x86 architecture, there is a .reloc section, but when I compile it in x64 architecture, the .reloc section does not exist. What is the…
fortyEight
  • 23
  • 4