Skip to main content

All Questions

Tagged with
2 votes
1 answer
48 views

Use symbol address to generate page table entry

I am working on writing a static paging setup for a custom bare-metal ARM system. ARMv7a uses two-level paging, where entries in a top-level page table can point to a second-level table. I have a top-...
George Hodgkins's user avatar
2 votes
0 answers
87 views

relative address instead of absolute address in the relocation table

In the context of compiler optimization and linker behavior, I'm trying to understand the implications of using relative addresses instead of absolute addresses in the relocation table during the ...
Alfa Hores's user avatar
5 votes
1 answer
268 views

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/...
Ricky's user avatar
  • 705
0 votes
1 answer
1k views

Relocation error happening locally but not in godbolt

Consider this program on godbolt: #include <cassert> #include <cstdint> int64_t const x[] = { 42, 2, 3, 4 }; int64_t f() { int64_t i; asm volatile ( "xor %[i], %[i]\n\t"...
Cassio Neri's user avatar
  • 20.4k
0 votes
0 answers
314 views

`auipc` and branch relaxation on RISC-V

For many tasks on RISC-V, a sequence ofauipc and an instruction with a short offset is used for PC-relative addressing (including jumps). This needs a temporary register. The GNU linker is capable of ...
David Monniaux's user avatar
4 votes
1 answer
350 views

Why can't I assemble absolute addresses in the .text section on ARM64 MacOS?

I'm writing in assembly using clang 13.1.6 with MacOS Monterey 12.5 on an ARM64 M1 Pro laptop. If I try to use .dword/.xword in the .text section with the address of a label as its value, my program ...
Nate Eldredge's user avatar
3 votes
1 answer
2k views

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 ...
Hut8's user avatar
  • 6,332
0 votes
1 answer
590 views

Cannot represent relocation type BFD_RELOC_X86_64_GOTPC64

I get this error whenever I try to use -mcmodel=large does anyone know why this is? I am on Windows 10 using gcc 10.2.0
Andrew Katson's user avatar
0 votes
1 answer
506 views

How does a linker relocate branch instructions in MIPS?

Background I'm working on a 2015 CS61C (Berkeley) course project on writing a linker to link object files generated from the following subset of the MIPS instruction set. Add Unsigned: addu $rd, $rs, $...
heckeop's user avatar
  • 407
0 votes
0 answers
198 views

Question about relocation entries in assembly code

I write 2 C programs : main.c and sum.c. Here is main.c : int array[2] = {1, 2}; int main() { int val = sum(array, 2); return val; } Here is sum.c : int sum(int* a, int n) { int i, s = 0; ...
dubugger's user avatar
  • 109
0 votes
0 answers
21 views

In object file produced by assembler what is the address used in places where linker is supposed to link the correct address? [duplicate]

So an assembler converts the assembly language code into an object file and a linker would then produce an executable file which we can use to execute the program. The job of linker is to link the ...
Charan Sai's user avatar
2 votes
1 answer
608 views

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 ...
Dewo's user avatar
  • 23
0 votes
1 answer
369 views

What are code Relocations ins AArch64, are they the same as the relocation for dynamic linking?

Reading the manual for GNU ASM I came across the syntax #:abs_g0_nc: and :pg_hi21:. This code loads different bit ranges of a value into a register, yet it is called relocation. I know what relocation ...
avin's user avatar
  • 13
2 votes
0 answers
170 views

How does an operating system change a process's virtual base address?

To clarify, my specific confusion is centered around the fact that all instructions in a PE executable are written assuming the base image address is = 00400000. However, when debugging an executable, ...
Horace's user avatar
  • 163
0 votes
1 answer
287 views

MS-DOS executable's [mov] instruction dynamic relocating at entry point

I've disassembled a MS-DOS Executable(16-bits) in IDA, the first instruction at entry point is mov ax, 0x1000 ; B8 00 10 However, when dumping raw hex, the corresponding field is mov ax, 0x0000 ; ...
3usi9's user avatar
  • 113

15 30 50 per page