[PATCH] [lld] [ELF] Fix wrong TBSS size

Adhemerval Zanella adhemerval.zanella at linaro.org
Tue Jun 16 10:41:17 PDT 2015


Hi ruiu, shankar.easwaran,

This patch fixes the wrong .tbss segment size generated for cases where
multiple modules have non initialized threads variables.  For instance:

-- t0.c --

__thread int x0;
__thread int x1;
__thread int x2;

extern __thread int e0;
extern __thread int e1;
extern __thread int e2;
extern __thread int e3;

int foo0 ()
{
  return x0;
}

int main ()
{
  return x0;
}

-- t1.c --

__thread int e0;
__thread int e1;
__thread int e2;
__thread int e3;

---

lld is generating (for aarch64):

  [14] .tbss             NOBITS           0000000000401000  00001000
       0000000000000010  0000000000000000 WAT       0     0     4

Where is just taking in consideration the largest tbss segment, not all
from all objects.  ld generates a correct output:

  [17] .tbss             NOBITS           0000000000410dec  00000dec
       000000000000001c  0000000000000000 WAT       0     0     4

This issue is at 'lib/ReaderWriter/ELF/SegmentChunks.cpp' where
Segment<ELFT>::assignVirtualAddress is setting wrong slice values, not taking care
of although tbss segments file size does noy play role in other segment virtual
address placement, its size should still be considered.

http://reviews.llvm.org/D10478

Files:
  lib/ReaderWriter/ELF/SegmentChunks.cpp
  test/elf/Inputs/tls-tbss-size.yaml
  test/elf/tls-tbss-size.test

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10478.27771.patch
Type: text/x-patch
Size: 11111 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150616/73bd49dd/attachment.bin>


More information about the llvm-commits mailing list