This is an archive of the discontinued LLVM Phabricator instance.

[ELF][X86] Allow PT_LOAD to have overlapping p_offset ranges on EM_386
ClosedPublic

Authored by MaskRay on Aug 7 2019, 5:55 AM.

Details

Summary

Ported the D64906 technique to EM_386.

If sh_addralign(.tdata) < sh_addralign(.tbss),
we can potentially make p_vaddr(PT_TLS)%p_align(PT_TLS) != 0.

ld.so that are known to have problems if p_vaddr%p_align!=0:

New test i386-tls-vaddr-align.s checks our workaround makes p_vaddr%p_align = 0.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Aug 7 2019, 5:55 AM

There are many expressions in the comments which are broken now (i.e. they were broken before this change already),
but also some of expressions were broken by this patch. I marked them in the comments.

test/ELF/i386-tls-opt-iele-nopic.s
38 ↗(On Diff #213860)

The last 2 need an update.

test/ELF/i386-tls-vaddr-align.s
1 ↗(On Diff #213860)

ppc?

test/ELF/plt-i686.s
123 ↗(On Diff #213860)

These are not valid anymore.

The others in this file too. Though they seems became broken before this change.

test/ELF/relocation-copy-i686.s
55 ↗(On Diff #213860)

Where? :)

test/ELF/relocation-i686.s
77 ↗(On Diff #213860)

This one is broken now.

MaskRay updated this revision to Diff 214085.Aug 8 2019, 2:00 AM
MaskRay marked 4 inline comments as done.

Update math

test/ELF/plt-i686.s
123 ↗(On Diff #213860)

I'll delete

// Unfortunately FileCheck can't do math, so we have to check for explicit
// values:

// 16 is the size of PLT[0]
// (0x401010 + 16) - (0x401000 + 1) - 4 = 27
// (0x401010 + 16) - (0x401005 + 1) - 4 = 22
// (0x401020 + 16) - (0x40100a + 1) - 4 = 33

Hopefully FileCheck will soon learn how to do math. (There is a patch series but it hasn't fully landed yet.)

jmp instructions are annotated with PLT entries so the math is no longer necessary.

MaskRay marked 3 inline comments as done.Aug 8 2019, 2:01 AM
MaskRay added inline comments.
test/ELF/i386-tls-opt-iele-nopic.s
38 ↗(On Diff #213860)

Just switched to llvm-objdump -d --print-imm-hex to make the formulae unnecessary.

grimar added a comment.Aug 8 2019, 6:18 AM

This looks fine to me.

ruiu accepted this revision.Aug 20 2019, 12:51 AM

LGTM

This revision is now accepted and ready to land.Aug 20 2019, 12:51 AM
MaskRay updated this revision to Diff 216071.Aug 20 2019, 1:40 AM
MaskRay marked an inline comment as done.
MaskRay edited the summary of this revision. (Show Details)

Update description

This revision was automatically updated to reflect the committed changes.