This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Fixed bug leading to miss of tls relocation when @tlsgd and @gottpoff relocations were used at the same time.
ClosedPublic

Authored by grimar on Dec 1 2015, 3:27 AM.

Details

Summary

Combination of @tlsgd and @gottpoff at the same time leads to miss of R_X86_64_TPOFF64 dynamic relocation. Patch fixes that.

@tlsgd(%rip) Allocate two contiguous entries in the GOT to hold a tls index
structure (for passing to tls get addr).

@gottpoff(%rip) Allocate one GOT entry to hold a variable offset in initial TLS
block (relative to TLS block end, %fs:0).

The same situation can be observed at for x86 (probably others too, not sure) with corresponding for that target relocations: @tlsgd, @gotntpoff.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 41480.Dec 1 2015, 3:27 AM
grimar retitled this revision from to [ELF] - x86, Fixed bug leading to miss of tls relocation when @tlsld and @gottpoff relocations were used at the same time..
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
grimar retitled this revision from [ELF] - x86, Fixed bug leading to miss of tls relocation when @tlsld and @gottpoff relocations were used at the same time. to [ELF] - x86, Fixed bug leading to miss of tls relocation when @tlsgd and @gottpoff relocations were used at the same time..Dec 1 2015, 3:43 AM
grimar updated this object.
grimar retitled this revision from [ELF] - x86, Fixed bug leading to miss of tls relocation when @tlsgd and @gottpoff relocations were used at the same time. to [ELF] - Fixed bug leading to miss of tls relocation when @tlsgd and @gottpoff relocations were used at the same time..Dec 1 2015, 7:14 AM
grimar updated this object.
ruiu added inline comments.Dec 1 2015, 9:18 AM
ELF/Symbols.h
93 ↗(On Diff #41480)

Glob -> Global

ELF/Writer.cpp
227 ↗(On Diff #41480)

Can you add a one-liner function for this comparison to SymbolBody, instead of comparing a value with -1?

grimar updated this revision to Diff 41538.Dec 1 2015, 11:11 AM

Review comments addressed.

grimar added inline comments.Dec 1 2015, 11:12 AM
ELF/Symbols.h
93 ↗(On Diff #41480)

Done.

ELF/Writer.cpp
227 ↗(On Diff #41480)

Done. But also simplified a little in the same way how was done for addLocalModelTlsIndex.

ruiu accepted this revision.Dec 1 2015, 11:17 AM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Dec 1 2015, 11:17 AM
This revision was automatically updated to reflect the committed changes.