Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ ELF/Target.cpp @@ -1417,14 +1417,25 @@ void AMDGPUTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const { - assert(Type == R_AMDGPU_REL32); - write32le(Loc, Val); + switch (Type) { + default: + llvm_unreachable("unsupported relocation type"); + case R_AMDGPU_ABS32: + case R_AMDGPU_REL32: + write32le(Loc, Val); + break; + } } RelExpr AMDGPUTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const { - if (Type != R_AMDGPU_REL32) - error("do not know how to handle relocation"); - return R_PC; + switch (Type) { + default: + llvm_unreachable("unsupported relocation type"); + case R_AMDGPU_ABS32: + return R_ABS; + case R_AMDGPU_REL32: + return R_PC; + } } ARMTargetInfo::ARMTargetInfo() { Index: test/ELF/amdgpu-relocs-abs32.s =================================================================== --- test/ELF/amdgpu-relocs-abs32.s +++ test/ELF/amdgpu-relocs-abs32.s @@ -0,0 +1,270 @@ +; RUN: llvm-mc -filetype=obj -triple=amdgcn--amdhsa -mcpu=fiji %s -o %t.o +; RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s + +; CHECK: DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000000] = "clang version 3.9.0 (trunk 273560)") +; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000023] = "relocs.cl") +; CHECK: DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x0000002d] = "/home/kzhuravl/Lightning/test") +; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000052] = "A") +; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000054] = "int") + + .text + .hsa_code_object_version 2,0 + .hsa_code_object_isa 8,0,3,"AMD","AMDGPU" + .section .AMDGPU.config + .text + .globl relocs + .p2align 8 + .type relocs,@function + .amdgpu_hsa_kernel relocs +relocs: ; @relocs +.Lfunc_begin0: + .file 1 "relocs.cl" + .loc 1 1 0 ; relocs.cl:1:0 + .amd_kernel_code_t + kernel_code_version_major = 1 + kernel_code_version_minor = 0 + machine_kind = 1 + machine_version_major = 8 + machine_version_minor = 0 + machine_version_stepping = 3 + kernel_code_entry_byte_offset = 256 + kernel_code_prefetch_byte_size = 0 + max_scratch_backing_memory_byte_size = 0 + compute_pgm_rsrc1_vgprs = 0 + compute_pgm_rsrc1_sgprs = 1 + compute_pgm_rsrc1_priority = 0 + compute_pgm_rsrc1_float_mode = 192 + compute_pgm_rsrc1_priv = 0 + compute_pgm_rsrc1_dx10_clamp = 1 + compute_pgm_rsrc1_debug_mode = 0 + compute_pgm_rsrc1_ieee_mode = 0 + compute_pgm_rsrc2_scratch_en = 0 + compute_pgm_rsrc2_user_sgpr = 6 + compute_pgm_rsrc2_tgid_x_en = 1 + compute_pgm_rsrc2_tgid_y_en = 0 + compute_pgm_rsrc2_tgid_z_en = 0 + compute_pgm_rsrc2_tg_size_en = 0 + compute_pgm_rsrc2_tidig_comp_cnt = 0 + compute_pgm_rsrc2_excp_en_msb = 0 + compute_pgm_rsrc2_lds_size = 0 + compute_pgm_rsrc2_excp_en = 0 + enable_sgpr_private_segment_buffer = 1 + enable_sgpr_dispatch_ptr = 0 + enable_sgpr_queue_ptr = 0 + enable_sgpr_kernarg_segment_ptr = 1 + enable_sgpr_dispatch_id = 0 + enable_sgpr_flat_scratch_init = 0 + enable_sgpr_private_segment_size = 0 + enable_sgpr_grid_workgroup_count_x = 0 + enable_sgpr_grid_workgroup_count_y = 0 + enable_sgpr_grid_workgroup_count_z = 0 + enable_ordered_append_gds = 0 + private_element_size = 1 + is_ptr64 = 1 + is_dynamic_callstack = 0 + is_debug_enabled = 0 + is_xnack_enabled = 0 + workitem_private_segment_byte_size = 0 + workgroup_group_segment_byte_size = 0 + gds_segment_byte_size = 0 + kernarg_segment_byte_size = 8 + workgroup_fbarrier_count = 0 + wavefront_sgpr_count = 12 + workitem_vgpr_count = 3 + reserved_vgpr_first = 0 + reserved_vgpr_count = 0 + reserved_sgpr_first = 0 + reserved_sgpr_count = 0 + debug_wavefront_private_segment_offset_sgpr = 0 + debug_private_segment_buffer_sgpr = 0 + kernarg_segment_alignment = 4 + group_segment_alignment = 4 + private_segment_alignment = 4 + wavefront_size = 6 + call_convention = 0 + runtime_loader_kernel_symbol = 0 + .end_amd_kernel_code_t +; BB#0: ; %entry + s_load_dwordx2 s[0:1], s[4:5], 0x0 +.Ltmp0: + .loc 1 2 6 prologue_end ; relocs.cl:2:6 + v_mov_b32_e32 v2, 0x7b + s_waitcnt lgkmcnt(0) + v_mov_b32_e32 v0, s0 + v_mov_b32_e32 v1, s1 + flat_store_dword v[0:1], v2 + .loc 1 3 1 ; relocs.cl:3:1 + s_endpgm +.Ltmp1: +.Lfunc_end0: + .size relocs, .Lfunc_end0-relocs + + .section .AMDGPU.csdata +; Kernel info: +; codeLenInByte = 36 +; NumSgprs: 12 +; NumVgprs: 3 +; FloatMode: 192 +; IeeeMode: 0 +; ScratchSize: 0 +; LDSByteSize: 0 bytes/workgroup (compile time only) +; ReservedVGPRFirst: 0 +; ReservedVGPRCount: 0 +; COMPUTE_PGM_RSRC2:USER_SGPR: 6 +; COMPUTE_PGM_RSRC2:TGID_X_EN: 1 +; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0 +; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0 +; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0 + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 3.9.0 (trunk 273560)" ; string offset=0 +.Linfo_string1: + .asciz "relocs.cl" ; string offset=35 +.Linfo_string2: + .asciz "/home/kzhuravl/Lightning/test" ; string offset=45 +.Linfo_string3: + .asciz "relocs" ; string offset=75 +.Linfo_string4: + .asciz "A" ; string offset=82 +.Linfo_string5: + .asciz "int" ; string offset=84 + .section .debug_loc + .section .debug_abbrev +.Lsection_abbrev: + .byte 1 ; Abbreviation Code + .byte 17 ; DW_TAG_compile_unit + .byte 1 ; DW_CHILDREN_yes + .byte 37 ; DW_AT_producer + .byte 14 ; DW_FORM_strp + .byte 19 ; DW_AT_language + .byte 5 ; DW_FORM_data2 + .byte 3 ; DW_AT_name + .byte 14 ; DW_FORM_strp + .byte 16 ; DW_AT_stmt_list + .byte 6 ; DW_FORM_data4 + .byte 27 ; DW_AT_comp_dir + .byte 14 ; DW_FORM_strp + .byte 17 ; DW_AT_low_pc + .byte 1 ; DW_FORM_addr + .byte 18 ; DW_AT_high_pc + .byte 1 ; DW_FORM_addr + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 2 ; Abbreviation Code + .byte 46 ; DW_TAG_subprogram + .byte 1 ; DW_CHILDREN_yes + .byte 17 ; DW_AT_low_pc + .byte 1 ; DW_FORM_addr + .byte 18 ; DW_AT_high_pc + .byte 1 ; DW_FORM_addr + .byte 3 ; DW_AT_name + .byte 14 ; DW_FORM_strp + .byte 58 ; DW_AT_decl_file + .byte 11 ; DW_FORM_data1 + .byte 59 ; DW_AT_decl_line + .byte 11 ; DW_FORM_data1 + .byte 39 ; DW_AT_prototyped + .byte 12 ; DW_FORM_flag + .byte 63 ; DW_AT_external + .byte 12 ; DW_FORM_flag + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 3 ; Abbreviation Code + .byte 5 ; DW_TAG_formal_parameter + .byte 0 ; DW_CHILDREN_no + .byte 3 ; DW_AT_name + .byte 14 ; DW_FORM_strp + .byte 58 ; DW_AT_decl_file + .byte 11 ; DW_FORM_data1 + .byte 59 ; DW_AT_decl_line + .byte 11 ; DW_FORM_data1 + .byte 73 ; DW_AT_type + .byte 19 ; DW_FORM_ref4 + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 4 ; Abbreviation Code + .byte 15 ; DW_TAG_pointer_type + .byte 0 ; DW_CHILDREN_no + .byte 73 ; DW_AT_type + .byte 19 ; DW_FORM_ref4 + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 5 ; Abbreviation Code + .byte 36 ; DW_TAG_base_type + .byte 0 ; DW_CHILDREN_no + .byte 3 ; DW_AT_name + .byte 14 ; DW_FORM_strp + .byte 62 ; DW_AT_encoding + .byte 11 ; DW_FORM_data1 + .byte 11 ; DW_AT_byte_size + .byte 11 ; DW_FORM_data1 + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 0 ; EOM(3) + .section .debug_info +.Lsection_info: +.Lcu_begin0: + .long 76 ; Length of Unit + .short 2 ; DWARF version number + .long .Lsection_abbrev ; Offset Into Abbrev. Section + .byte 4 ; Address Size (in bytes) + .byte 1 ; Abbrev [1] 0xb:0x45 DW_TAG_compile_unit + .long .Linfo_string0 ; DW_AT_producer + .short 12 ; DW_AT_language + .long .Linfo_string1 ; DW_AT_name + .long .Lline_table_start0 ; DW_AT_stmt_list + .long .Linfo_string2 ; DW_AT_comp_dir + .long .Lfunc_begin0 ; DW_AT_low_pc + .long .Lfunc_end0 ; DW_AT_high_pc + .byte 2 ; Abbrev [2] 0x26:0x1d DW_TAG_subprogram + .long .Lfunc_begin0 ; DW_AT_low_pc + .long .Lfunc_end0 ; DW_AT_high_pc + .long .Linfo_string3 ; DW_AT_name + .byte 1 ; DW_AT_decl_file + .byte 1 ; DW_AT_decl_line + .byte 1 ; DW_AT_prototyped + .byte 1 ; DW_AT_external + .byte 3 ; Abbrev [3] 0x37:0xb DW_TAG_formal_parameter + .long .Linfo_string4 ; DW_AT_name + .byte 1 ; DW_AT_decl_file + .byte 1 ; DW_AT_decl_line + .long 67 ; DW_AT_type + .byte 0 ; End Of Children Mark + .byte 4 ; Abbrev [4] 0x43:0x5 DW_TAG_pointer_type + .long 72 ; DW_AT_type + .byte 5 ; Abbrev [5] 0x48:0x7 DW_TAG_base_type + .long .Linfo_string5 ; DW_AT_name + .byte 5 ; DW_AT_encoding + .byte 4 ; DW_AT_byte_size + .byte 0 ; End Of Children Mark + .section .debug_ranges +.Ldebug_range: + .section .debug_macinfo +.Ldebug_macinfo: +.Lcu_macro_begin0: + .byte 0 ; End Of Macro List Mark + .section .debug_pubnames + .long .LpubNames_end0-.LpubNames_begin0 ; Length of Public Names Info +.LpubNames_begin0: + .short 2 ; DWARF Version + .long .Lcu_begin0 ; Offset of Compilation Unit Info + .long 80 ; Compilation Unit Length + .long 38 ; DIE offset + .asciz "relocs" ; External Name + .long 0 ; End Mark +.LpubNames_end0: + .section .debug_pubtypes + .long .LpubTypes_end0-.LpubTypes_begin0 ; Length of Public Types Info +.LpubTypes_begin0: + .short 2 ; DWARF Version + .long .Lcu_begin0 ; Offset of Compilation Unit Info + .long 80 ; Compilation Unit Length + .long 72 ; DIE offset + .asciz "int" ; External Name + .long 0 ; End Mark +.LpubTypes_end0: + + .ident "clang version 3.9.0 (trunk 273560)" + .section ".note.GNU-stack" + .section .debug_line +.Lline_table_start0: