# zld: adjust signed displacement source target addr · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/f67e756211b6e69cc8fadbb6b1ec5af1bd5c7049)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: f67e756211b6e69cc8fadbb6b1ec5af1bd5c7049

Requested commit: f67e756211b6e69cc8fadbb6b1ec5af1bd5c7049

Commit: f67e756211b6e69cc8fadbb6b1ec5af1bd5c7049

Tree: 69d8704e34a0855ca855de3cf096df26b6b5eced

Author: Jakub Konka

Committer: Jakub Konka

## Message

```
zld: adjust signed displacement source target addr

Previously, I mistakenly assumed that offset of the relocation
is enough when calculating relative offset of the target from the
source target section base address in case of section-based relocs
on x86_64. While this is true for `__TEXT,__text` section which
always starts at 0x0 in object files, this is absolutely not true
for `__TEXT,__StaticInit` section which will have nonzero base
address hence resulting in incorrect displacement calculations for
SIGNED relocs.

```

## Parents

- [15d6efecfbe8be46e5dbd7765f0ef9726144db5d](https://git.cafe/gitcafe/zig/commit/15d6efecfbe8be46e5dbd7765f0ef9726144db5d?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/f67e756211b6e69cc8fadbb6b1ec5af1bd5c7049?format=markdown)
