[PATCH] D23751: [ELF] Linkerscript: define symbols outside SECTIONS

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 09:17:42 PDT 2016


phosek added a comment.

I tested the support for multiple `SECTIONS` commands in Binutils ld and gold using the following script:

  foo = 0x1000;
  SECTIONS {
    bar = foo + 0x10;
  }
  baz = bar + 0x20;
  SECTIONS {
    qux = baz + 0x30;
  }
  quux = qux + 0x40

ld handles this correctly producing:

  0000000000001000     0 NOTYPE  GLOBAL DEFAULT  ABS foo
  0000000000001010     0 NOTYPE  GLOBAL DEFAULT  ABS bar
  0000000000001030     0 NOTYPE  GLOBAL DEFAULT  ABS baz
  0000000000001060     0 NOTYPE  GLOBAL DEFAULT  ABS qux
  00000000000010a0     0 NOTYPE  GLOBAL DEFAULT  ABS quux

gold produces a different output which doesn't seem correct:

  0000000000001000     0 NOTYPE  GLOBAL DEFAULT  ABS foo
  0000000000001010     0 NOTYPE  GLOBAL DEFAULT  ABS bar
  0000000000001030     0 NOTYPE  GLOBAL DEFAULT  ABS baz
  0000000000000050     0 NOTYPE  GLOBAL DEFAULT  ABS qux
  0000000000000090     0 NOTYPE  GLOBAL DEFAULT  ABS quux

So given that, maybe support for multiple `SECTIONS` commands is not necessary. Old ld manual <https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_3.html> even explicitly says that "You may use at most one SECTIONS command in a script file", although I couldn't find the same statement in the current one.


https://reviews.llvm.org/D23751





More information about the llvm-commits mailing list