This is an archive of the discontinued LLVM Phabricator instance.

[ELF][test] Add testing for dynamic TLS relocations in .debug_info
ClosedPublic

Authored by andrewng on Oct 8 2021, 9:22 AM.

Diff Detail

Event Timeline

andrewng created this revision.Oct 8 2021, 9:22 AM
andrewng requested review of this revision.Oct 8 2021, 9:22 AM

Please place this in one of the x86-64-tls-ld*.s files. For ppc64 we use ppc64-dtprel.s

lld/test/ELF/relocation-dyn-tls-debug-info.s
31 ↗(On Diff #378269)

Two values should be sufficient.

You can use .quad 0 or .space to add a gap if you think 0 as a value is too special.

MaskRay added inline comments.Oct 8 2021, 9:54 AM
lld/test/ELF/relocation-dyn-tls-debug-info.s
10 ↗(On Diff #378269)

Drop --gc-sections from this test. It doesn't do anything special.

The property is tested in debug-dead-reloc* files.

Please place this in one of the x86-64-tls-ld*.s files. For ppc64 we use ppc64-dtprel.s

This test is testing the patching behaviour of DTPREL in non-alloc sections, specifically .debug_info because that's the usual use case, so I'm not sure it really fits with the x86-64-tls-ld*.s tests. Do you want me to rename this test to x86-64-dtprel.s or do you have another suggestion?

lld/test/ELF/relocation-dyn-tls-debug-info.s
10 ↗(On Diff #378269)

The focus of this testing is the following code from InputSection::relocateNonAlloc in InputSection.cpp:

if (tombstone ||
    (isDebug && (type == target->symbolicRel || expr == R_DTPREL))) {

This is why I added --gc-sections because although the actual behaviour now is not special there is this specific code path. However, thanks for spotting debug-dead-reloc-tls.s which already provides coverage. Not sure how I managed to miss this in my search for existing coverage. I will remove this --gc-sections test case.

31 ↗(On Diff #378269)

Yes, two values are sufficient, the third value was really for the --gc-sections test case which is no longer required.

Please place this in one of the x86-64-tls-ld*.s files. For ppc64 we use ppc64-dtprel.s

This test is testing the patching behaviour of DTPREL in non-alloc sections, specifically .debug_info because that's the usual use case, so I'm not sure it really fits with the x86-64-tls-ld*.s tests. Do you want me to rename this test to x86-64-dtprel.s or do you have another suggestion?

DTPREL relocations are used in the local-dynamic TLS model. The non-alloc section context is slightly different, but I think just reusing one file is fine (in this case I think fewer tests are easier to organize).

andrewng updated this revision to Diff 378621.Oct 11 2021, 4:23 AM

Address review comments and moved testing to x86-64-tls-ld-local.s.

andrewng marked 2 inline comments as done.Oct 11 2021, 4:24 AM
MaskRay accepted this revision.Oct 11 2021, 12:58 PM

LGTM.

This revision is now accepted and ready to land.Oct 11 2021, 12:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2021, 2:55 AM