[PATCH] D63869: [ELF] Do not produce DT_JMPREL and DT_PLTGOT if .rela.plt is empty.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 04:20:27 PDT 2019


ikudrin added a comment.

On Linux, the issue can be reproduced in the following way:

  // d.c
  long val[3];
  long getval(int i) {return val[i];}

  // main.c
  #include <stdio.h>
  
  long getval(int i);
  
  int main() {
    for (int i = 0; i < 3; ++i)
      printf("val[%d] = %ld\n", i, getval(i));
    return 0;
  }

  # d.t
  PHDRS {
      all PT_LOAD;
      dyn PT_DYNAMIC;
  }
  SECTIONS {
      .rela.plt : {*(.rela.plt)}: all
      .dynamic : {*(.dynamic)}: all : dyn
      .got.plt : {*(.got.plt)}: all
      .bss : {*(.bss)}: all
  }

  $ clang d.c -nostdlib -fPIC -shared -o d.so -fuse-ld=lld -Wl,-T,d.t
  $ clang main.c ./d.so -fpie -o test -fuse-ld=lld
  $ ./test
  val[0] = 0
  val[1] = 140495953956864
  val[2] = 140495951804032


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D63869





More information about the llvm-commits mailing list