Skip to content

Instantly share code, notes, and snippets.

@evanrichter
Created February 16, 2022 18:45
Show Gist options
  • Select an option

  • Save evanrichter/9bdc0235c656b727de07cfeb66e083df to your computer and use it in GitHub Desktop.

Select an option

Save evanrichter/9bdc0235c656b727de07cfeb66e083df to your computer and use it in GitHub Desktop.
absolute call mold bug
[evan@arch mold-break]$ cat absolute_call.c
#include <stddef.h>
int main(void) {
size_t x = 0x12340000;
void (*f)() = (void (*)())x;
f();
}
# here is current mold built with build-static.sh
[evan@arch mold-break]$ /home/evan/projects/mold/mold -v
mold 1.0.3 (da48efe63ba2b073bff237daa5aa7d379764bba1; compatible with GNU ld)
[evan@arch mold-break]$ clang absolute_call.c -m32 -O3 -fuse-ld=/home/evan/projects/mold/mold
clang-13: error: unable to execute command: Segmentation fault (core dumped)
clang-13: error: linker command failed due to signal (use -v to see invocation)
# with system mold, release 1.0.3
[evan@arch mold-break]$ /usr/bin/mold -v
mold 1.0.3 (bda68f94a4cb6b01649bb15865d6a6fecbef9db9; compatible with GNU ld)
[evan@arch mold-break]$ clang absolute_call.c -m32 -O3 -fuse-ld=/usr/bin/mold
[evan@arch mold-break]$ objdump -Mintel -d a.out | rg "call 123"
[evan@arch mold-break]$ objdump -Mintel -d a.out | rg "call.*123"
11a0: e8 fb ff 33 12 call 123411a0 <_end+0x1233e187>
[evan@arch mold-break]$ clang -v
clang version 13.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment