Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -2241,7 +2241,9 @@ // 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) Index: test/ELF/amdgpu-relocs.s =================================================================== --- test/ELF/amdgpu-relocs.s +++ test/ELF/amdgpu-relocs.s @@ -94,7 +94,7 @@ # 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 @@ -114,16 +114,16 @@ # 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