[PATCH] D97448: ELF: Create unique SHF_GNU_RETAIN sections for llvm.used global objects

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 8 14:21:27 PDT 2021


nikic added a comment.

Just FYI this patch exposes a bug in at least `GNU gold (GNU Binutils for Ubuntu 2.34) 1.16` when used in conjunction with `section(".init_array")`.

  ; RUN: clang -fuse-ld=gold %s
  #include <stdio.h>
  static void do_init(void) { printf("Foobar\n"); }
  
  __attribute__((used, retain, section(".init_array")))
  static void (*init)(void) = &do_init;
  
  int main() { return 0; }

The symbol is not placed between `__init_array_start`/`__init_array_end` and thus the init function is not run.

Following your recommendation, we switched the `#[used]` attribute in rust to use `llvm.compiler.used` instead of `llvm.used`. Hopefully that won't have other fallout.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97448/new/

https://reviews.llvm.org/D97448



More information about the llvm-commits mailing list