[PATCH] D29391: [ELF] - Postpone the evaluation of DefinedSynthetic value

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 04:43:22 PST 2017


grimar created this revision.

After applying https://reviews.llvm.org/D29332 and trying to link linux kernel I found next issue.
We still produced symbols value wrong.

Having the next script:

  vvar_start = . - 2 * (1 << 12);
  vvar_page = vvar_start;
  vvar_vsyscall_gtod_data = vvar_page + 128;

LLD output was:

  Section Headers:
    [Nr] Name              Type             Address           Offset
    [ 1] .hash             HASH             0000000000000120  00000120
         0000000000000050  0000000000000004   A       3     0     4
  
  Symbol table '.symtab' contains 18 entries:
     Num:    Value          Size Type    Bind   Vis      Ndx Name
       3: ffffffffffffe1a0     0 NOTYPE  LOCAL  HIDDEN     1 vvar_vsyscall_gtod_data
       5: ffffffffffffe120     0 NOTYPE  LOCAL  DEFAULT    1 vvar_start
       6: ffffffffffffe120     0 NOTYPE  LOCAL  DEFAULT    1 vvar_page

BFD was:

  28: ffffffffffffe000     0 NOTYPE  LOCAL  DEFAULT  ABS vvar_page
  33: ffffffffffffe000     0 NOTYPE  LOCAL  DEFAULT    1 vvar_start
  35: ffffffffffffe080     0 NOTYPE  LOCAL  DEFAULT  ABS vvar_vsyscall_gtod_data

GOLD was:

  6: ffffffffffffe000     0 NOTYPE  LOCAL  DEFAULT  ABS vvar_start
  7: ffffffffffffe000     0 NOTYPE  LOCAL  DEFAULT  ABS vvar_page
  8: ffffffffffffe080     0 NOTYPE  LOCAL  DEFAULT  ABS vvar_vsyscall_gtod_data

The problem was in assignSectionSymbol(). We used Body->Section->Addr too early.
At the point of evaluation Addr was unset and == 0x0. Solution I suggest - to postpone the evaluation.
After that patch values we produce are correct for case above.


https://reviews.llvm.org/D29391

Files:
  ELF/LinkerScript.cpp
  ELF/Symbols.cpp
  ELF/Symbols.h
  ELF/Writer.cpp
  test/ELF/linkerscript/non-absolute.s
  test/ELF/linkerscript/symbols-synthetic.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29391.86618.patch
Type: text/x-patch
Size: 4940 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170201/fe54eaf6/attachment.bin>


More information about the llvm-commits mailing list