Skip to content

Commit

Permalink
[ELF][AMDGPU] Avoid PT_LOAD to have overlapping p_offset range
Browse files Browse the repository at this point in the history
Changes introduced in commit https://llvm.org/svn/llvm-project/lld/trunk@370180
allows PT_LOAD to have overlapping p_offset ranges on EM_AMDGPU and
EM_SPARCV9. However this is introducing crash as described in internal issue
SWDEV-203875. It is disabled for AMDGPU.

Change-Id: Idf42b7ac56940bd83414fe83f0e4ae57693245e8
  • Loading branch information
Dineshkumar Bhaskaran committed Oct 11, 2019
1 parent e5162a6 commit 8a7fd96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion ELF/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,9 @@ template <class ELFT> void Writer<ELFT>::fixSectionAlignments() {
// maximum page size boundary so that we can find the ELF header at the
// start. We cannot benefit from overlapping p_offset ranges with the
// previous segment anyway.
if (config->zSeparate == SeparateSegmentKind::Loadable ||
bool enable = config->emachine != EM_AMDGPU;

if (!enable || config->zSeparate == SeparateSegmentKind::Loadable ||
(config->zSeparate == SeparateSegmentKind::Code && prev &&
(prev->p_flags & PF_X) != (p->p_flags & PF_X)) ||
cmd->type == SHT_LLVM_PART_EHDR)
Expand Down
18 changes: 9 additions & 9 deletions test/ELF/amdgpu-relocs.s
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ foo:
# linker.
# CHECK: Relocations [
# CHECK: .rela.dyn {
# CHECK-NEXT: R_AMDGPU_RELATIVE64 - 0x3928
# CHECK-NEXT: R_AMDGPU_RELATIVE64 - 0x3008
# CHECK-NEXT: R_AMDGPU_ABS64 common_var0 0x0
# CHECK-NEXT: R_AMDGPU_ABS64 common_var1 0x0
# CHECK-NEXT: R_AMDGPU_ABS64 common_var2 0x0
Expand All @@ -114,16 +114,16 @@ foo:
# CHECK-NEXT: }
# CHECK-NEXT: ]

# NM: 0000000000003930 B common_var0
# NM: 0000000000003d30 B common_var1
# NM: 0000000000004130 B common_var2
# NM: 0000000000003928 d temp2
# NM: 0000000000003010 B common_var0
# NM: 0000000000003410 B common_var1
# NM: 0000000000003810 B common_var2
# NM: 0000000000003008 d temp2

# temp2 - foo = 0x3928-0x768 = 0x31c0
# temp2 - foo = 0x3008-0x768 = 0x28a0
# HEX: section '.rodata':
# HEX-NEXT: 0x00000768 c0310000 00000000
# HEX-NEXT: 0x00000768 a0280000 00000000

# common_var2+4, common_var1+8, and common_var0+12.
# HEX: section 'nonalloc':
# HEX-NEXT: 0x00000000 00000000 34410000 00000000 383d0000
# HEX-NEXT: 0x00000010 00000000 3c390000
# HEX-NEXT: 0x00000000 00000000 14380000 00000000 18340000
# HEX-NEXT: 0x00000010 00000000 1c300000

0 comments on commit 8a7fd96

Please sign in to comment.