Index: llvm/lib/MC/MCContext.cpp =================================================================== --- llvm/lib/MC/MCContext.cpp +++ llvm/lib/MC/MCContext.cpp @@ -652,6 +652,7 @@ StringRef CachedName = Entry.first.SectionName; MCSymbol *Begin = createSymbol(CachedName, true, false); + Symbols[Begin->getName()] = Begin; cast(Begin)->setType(wasm::WASM_SYMBOL_TYPE_SECTION); MCSectionWasm *Result = new (WasmAllocator.Allocate()) Index: llvm/test/MC/WebAssembly/comdat-sections.s =================================================================== --- llvm/test/MC/WebAssembly/comdat-sections.s +++ llvm/test/MC/WebAssembly/comdat-sections.s @@ -1,50 +1,217 @@ -# RUN: llvm-mc -triple=wasm32 -filetype=obj %s -o - | obj2yaml | FileCheck %s + .text + .file "t.cpp" + .file 1 "/home/probinson/projects/scratch\\t.cpp" + .section .debug_types,"G",@,4721183873463917179,comdat + .int32 .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .int16 4 # DWARF version number + .int32 .debug_abbrev0 # Offset Into Abbrev. Section + .int8 4 # Address Size (in bytes) + .int64 4721183873463917179 # Type Signature + .int32 30 # Type DIE Offset + .int8 1 # Abbrev [1] 0x17:0x24 DW_TAG_type_unit + .int16 4 # DW_AT_language + .int32 .Lline_table_start0 # DW_AT_stmt_list + .int8 2 # Abbrev [2] 0x1e:0x15 DW_TAG_structure_type + .int32 .Linfo_string6 # DW_AT_name + .int8 4 # DW_AT_byte_size + .int8 1 # DW_AT_decl_file + .int8 1 # DW_AT_decl_line + .int8 3 # Abbrev [3] 0x26:0xc DW_TAG_member + .int32 .Linfo_string4 # DW_AT_name + .int32 51 # DW_AT_type + .int8 1 # DW_AT_decl_file + .int8 2 # DW_AT_decl_line + .int8 0 # DW_AT_data_member_location + .int8 0 # End Of Children Mark + .int8 4 # Abbrev [4] 0x33:0x7 DW_TAG_base_type + .int32 .Linfo_string5 # DW_AT_name + .int8 5 # DW_AT_encoding + .int8 4 # DW_AT_byte_size + .int8 0 # End Of Children Mark +.Ldebug_info_end0: + .type s,@object # @s + .section .bss.s,"",@ + .globl s + .p2align 2 +s: + .skip 4 + .size s, 4 - .section .text.foo,"G",@,abc123,comdat - .globl foo - .type foo,@function -foo: - .functype foo () -> () - return - end_function - - .globl bar -bar: - .functype bar () -> () - return - end_function - - .section .debug_foo,"G",@,abc123,comdat - .int32 42 - .section .debug_foo,"G",@,duplicate,comdat - .int64 234 - -# Check that there are 2 identically-named custom sections, with the desired -# contents -# CHECK: - Type: CUSTOM -# CHECK-NEXT: Name: .debug_foo -# CHECK-NEXT: Payload: 2A000000 -# CHECK-NEXT: - Type: CUSTOM -# CHECK-NEXT: Name: .debug_foo -# CHECK-NEXT: Payload: EA00000000000000 - -# And check that they are in 2 different comdat groups -# CHECK-NEXT:- Type: CUSTOM -# CHECK-NEXT: Name: linking -# CHECK-NEXT: Version: 2 -# CHECK: Comdats: -# CHECK-NEXT: - Name: abc123 -# CHECK-NEXT: Entries: -# CHECK-NEXT: - Kind: FUNCTION -# CHECK-NEXT: Index: 0 - -# If the user forgets to create a new section for a function, one is created for -# them by the assembler. Check that it is also in the same group. -# CHECK-NEXT: - Kind: FUNCTION -# CHECK-NEXT: Index: 1 -# CHECK-NEXT: - Kind: SECTION -# CHECK-NEXT: Index: 4 -# CHECK-NEXT: - Name: duplicate -# CHECK-NEXT: Entries: -# CHECK-NEXT: - Kind: SECTION -# CHECK-NEXT: Index: 5 + .section .debug_abbrev,"",@ + .int8 1 # Abbreviation Code + .int8 65 # DW_TAG_type_unit + .int8 1 # DW_CHILDREN_yes + .int8 19 # DW_AT_language + .int8 5 # DW_FORM_data2 + .int8 16 # DW_AT_stmt_list + .int8 23 # DW_FORM_sec_offset + .int8 0 # EOM(1) + .int8 0 # EOM(2) + .int8 2 # Abbreviation Code + .int8 19 # DW_TAG_structure_type + .int8 1 # DW_CHILDREN_yes + .int8 3 # DW_AT_name + .int8 14 # DW_FORM_strp + .int8 11 # DW_AT_byte_size + .int8 11 # DW_FORM_data1 + .int8 58 # DW_AT_decl_file + .int8 11 # DW_FORM_data1 + .int8 59 # DW_AT_decl_line + .int8 11 # DW_FORM_data1 + .int8 0 # EOM(1) + .int8 0 # EOM(2) + .int8 3 # Abbreviation Code + .int8 13 # DW_TAG_member + .int8 0 # DW_CHILDREN_no + .int8 3 # DW_AT_name + .int8 14 # DW_FORM_strp + .int8 73 # DW_AT_type + .int8 19 # DW_FORM_ref4 + .int8 58 # DW_AT_decl_file + .int8 11 # DW_FORM_data1 + .int8 59 # DW_AT_decl_line + .int8 11 # DW_FORM_data1 + .int8 56 # DW_AT_data_member_location + .int8 11 # DW_FORM_data1 + .int8 0 # EOM(1) + .int8 0 # EOM(2) + .int8 4 # Abbreviation Code + .int8 36 # DW_TAG_base_type + .int8 0 # DW_CHILDREN_no + .int8 3 # DW_AT_name + .int8 14 # DW_FORM_strp + .int8 62 # DW_AT_encoding + .int8 11 # DW_FORM_data1 + .int8 11 # DW_AT_byte_size + .int8 11 # DW_FORM_data1 + .int8 0 # EOM(1) + .int8 0 # EOM(2) + .int8 5 # Abbreviation Code + .int8 17 # DW_TAG_compile_unit + .int8 1 # DW_CHILDREN_yes + .int8 37 # DW_AT_producer + .int8 14 # DW_FORM_strp + .int8 19 # DW_AT_language + .int8 5 # DW_FORM_data2 + .int8 3 # DW_AT_name + .int8 14 # DW_FORM_strp + .int8 16 # DW_AT_stmt_list + .int8 23 # DW_FORM_sec_offset + .int8 27 # DW_AT_comp_dir + .int8 14 # DW_FORM_strp + .ascii "\264B" # DW_AT_GNU_pubnames + .int8 25 # DW_FORM_flag_present + .int8 0 # EOM(1) + .int8 0 # EOM(2) + .int8 6 # Abbreviation Code + .int8 52 # DW_TAG_variable + .int8 0 # DW_CHILDREN_no + .int8 3 # DW_AT_name + .int8 14 # DW_FORM_strp + .int8 73 # DW_AT_type + .int8 19 # DW_FORM_ref4 + .int8 63 # DW_AT_external + .int8 25 # DW_FORM_flag_present + .int8 58 # DW_AT_decl_file + .int8 11 # DW_FORM_data1 + .int8 59 # DW_AT_decl_line + .int8 11 # DW_FORM_data1 + .int8 2 # DW_AT_location + .int8 24 # DW_FORM_exprloc + .int8 0 # EOM(1) + .int8 0 # EOM(2) + .int8 7 # Abbreviation Code + .int8 19 # DW_TAG_structure_type + .int8 0 # DW_CHILDREN_no + .int8 60 # DW_AT_declaration + .int8 25 # DW_FORM_flag_present + .int8 105 # DW_AT_signature + .int8 32 # DW_FORM_ref_sig8 + .int8 0 # EOM(1) + .int8 0 # EOM(2) + .int8 0 # EOM(3) + .section .debug_info,"",@ +.Lcu_begin0: + .int32 .Ldebug_info_end1-.Ldebug_info_start1 # Length of Unit +.Ldebug_info_start1: + .int16 4 # DWARF version number + .int32 .debug_abbrev0 # Offset Into Abbrev. Section + .int8 4 # Address Size (in bytes) + .int8 5 # Abbrev [5] 0xb:0x2e DW_TAG_compile_unit + .int32 .Linfo_string0 # DW_AT_producer + .int16 4 # DW_AT_language + .int32 .Linfo_string1 # DW_AT_name + .int32 .Lline_table_start0 # DW_AT_stmt_list + .int32 .Linfo_string2 # DW_AT_comp_dir + # DW_AT_GNU_pubnames + .int8 6 # Abbrev [6] 0x1e:0x11 DW_TAG_variable + .int32 .Linfo_string3 # DW_AT_name + .int32 47 # DW_AT_type + # DW_AT_external + .int8 1 # DW_AT_decl_file + .int8 5 # DW_AT_decl_line + .int8 5 # DW_AT_location + .int8 3 + .int32 s + .int8 7 # Abbrev [7] 0x2f:0x9 DW_TAG_structure_type + # DW_AT_declaration + .int64 4721183873463917179 # DW_AT_signature + .int8 0 # End Of Children Mark +.Ldebug_info_end1: + .section .debug_str,"",@ +.Linfo_string0: + .asciz "clang version 5.0.0 (trunk 295942)" # string offset=0 +.Linfo_string1: + .asciz "t.cpp" # string offset=35 +.Linfo_string2: + .asciz "/home/probinson/projects/scratch" # string offset=41 +.Linfo_string3: + .asciz "s" # string offset=74 +.Linfo_string4: + .asciz "s1" # string offset=76 +.Linfo_string5: + .asciz "int" # string offset=79 +.Linfo_string6: + .asciz "S" # string offset=83 + .section .debug_pubnames,"",@ + .int32 .LpubNames_end0-.LpubNames_begin0 # Length of Public Names Info +.LpubNames_begin0: + .int16 2 # DWARF Version + .int32 .Lcu_begin0 # Offset of Compilation Unit Info + .int32 57 # Compilation Unit Length + .int32 30 # DIE offset + .asciz "s" # External Name + .int32 0 # End Mark +.LpubNames_end0: + .section .debug_pubtypes,"",@ + .int32 .LpubTypes_end0-.LpubTypes_begin0 # Length of Public Types Info +.LpubTypes_begin0: + .int16 2 # DWARF Version + .int32 .Lcu_begin0 # Offset of Compilation Unit Info + .int32 57 # Compilation Unit Length + .int32 47 # DIE offset + .asciz "S" # External Name + .int32 11 # DIE offset + .asciz "int" # External Name + .int32 0 # End Mark +.LpubTypes_end0: + .ident "clang version 5.0.0 (trunk 295942)" + .section .custom_section.producers,"",@ + .int8 2 + .int8 8 + .ascii "language" + .int8 1 + .int8 11 + .ascii "C_plus_plus" + .int8 0 + .int8 12 + .ascii "processed-by" + .int8 1 + .int8 5 + .ascii "clang" + .int8 20 + .ascii "5.0.0 (trunk 295942)" + .section .debug_pubtypes,"",@ + .section .debug_line,"",@ +.Lline_table_start0: Index: llvm/test/MC/WebAssembly/section-symbol.s =================================================================== --- /dev/null +++ llvm/test/MC/WebAssembly/section-symbol.s @@ -0,0 +1,14 @@ +# RUN: llvm-mc -triple=wasm32 < %s | FileCheck %s + +# check that we can refer to section symbols of other sections. +# getWasmSection currently forces the section symbol to have a suffix. + + .section .debug_abbrev,"",@ + .int8 1 + .section .debug_info,"",@ + .int32 .debug_abbrev0 + +# CHECK: .section .debug_abbrev,"",@ +# CHECK-NEXT: .int8 1 +# CHECK-NEXT: .section .debug_info,"",@ +# CHECK-NEXT: .int32 .debug_abbrev0