diff --git a/lld/test/MachO/symtab.s b/lld/test/MachO/symtab.s --- a/lld/test/MachO/symtab.s +++ b/lld/test/MachO/symtab.s @@ -73,6 +73,7 @@ # CHECK-NEXT: Section: (0x0) # CHECK-NEXT: RefType: UndefinedNonLazy (0x0) # CHECK-NEXT: Flags [ (0x100) +# CHECK-NEXT: SymbolResolver (0x100) # CHECK-NEXT: ] # CHECK-NEXT: Value: 0x0 # CHECK-NEXT: } diff --git a/llvm/test/MC/MachO/ARM/darwin-Thumb-reloc.s b/llvm/test/MC/MachO/ARM/darwin-Thumb-reloc.s --- a/llvm/test/MC/MachO/ARM/darwin-Thumb-reloc.s +++ b/llvm/test/MC/MachO/ARM/darwin-Thumb-reloc.s @@ -92,8 +92,9 @@ @ CHECK: Extern @ CHECK: Type: Section (0xE) @ CHECK: Section: __text (0x1) -@ CHECK: RefType: 0x8 -@ CHECK: Flags [ (0x0) +@ CHECK: RefType: UndefinedNonLazy (0x0) +@ CHECK: Flags [ (0x8) +@ CHECK: ThumbDef (0x8) @ CHECK: ] @ CHECK: Value: 0x0 @ CHECK: } diff --git a/llvm/test/tools/llvm-objcopy/MachO/symbol-table.test b/llvm/test/tools/llvm-objcopy/MachO/symbol-table.test --- a/llvm/test/tools/llvm-objcopy/MachO/symbol-table.test +++ b/llvm/test/tools/llvm-objcopy/MachO/symbol-table.test @@ -180,6 +180,7 @@ # CHECK-NEXT: RefType: UndefinedNonLazy (0x0) # CHECK-NEXT: Flags [ (0xFE00) # CHECK-NEXT: AltEntry (0x200) +# CHECK-NEXT: ColdFunc (0x400) # CHECK-NEXT: ] # CHECK-NEXT: Value: 0x0 # CHECK-NEXT: } @@ -190,6 +191,7 @@ # CHECK-NEXT: Section: (0x0) # CHECK-NEXT: RefType: UndefinedNonLazy (0x0) # CHECK-NEXT: Flags [ (0x100) +# CHECK-NEXT: SymbolResolver (0x100) # CHECK-NEXT: ] # CHECK-NEXT: Value: 0x0 # CHECK-NEXT: } diff --git a/llvm/test/tools/llvm-readobj/MachO/flags.yaml b/llvm/test/tools/llvm-readobj/MachO/flags.yaml new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-readobj/MachO/flags.yaml @@ -0,0 +1,74 @@ +## Verify that llvm-readobj can dump the various symbol flags correctly. +# RUN: yaml2obj %s -o %t +# RUN: llvm-readobj --syms %t | FileCheck %s + +# CHECK: Symbols [ +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: _foo (1) +# CHECK-NEXT: Extern +# CHECK-NEXT: Type: Section (0xE) +# CHECK-NEXT: Section: __text (0x1) +# CHECK-NEXT: RefType: UndefinedNonLazy (0x0) +# CHECK-NEXT: Flags [ (0x128) +# CHECK-NEXT: NoDeadStrip (0x20) +# CHECK-NEXT: SymbolResolver (0x100) +# CHECK-NEXT: ThumbDef (0x8) +# CHECK-NEXT: ] +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: } +# CHECK-NEXT: ] + +--- !mach-o +FileHeader: + magic: 0xFEEDFACE + cputype: 0xC + cpusubtype: 0x9 + filetype: 0x1 + ncmds: 2 + sizeofcmds: 228 + flags: 0x0 +LoadCommands: + - cmd: LC_SEGMENT + cmdsize: 124 + segname: '' + vmaddr: 0 + vmsize: 0 + fileoff: 256 + filesize: 0 + maxprot: 7 + initprot: 7 + nsects: 1 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0 + size: 0 + offset: 0x100 + align: 2 + reloff: 0x0 + nreloc: 0 + flags: 0x80000000 + reserved1: 0x0 + reserved2: 0x0 + reserved3: 0x0 + content: '' + - cmd: LC_SYMTAB + cmdsize: 24 + symoff: 256 + nsyms: 1 + stroff: 268 + strsize: 8 +LinkEditData: + NameList: + - n_strx: 1 + n_type: 0xF + n_sect: 1 + n_desc: 296 + n_value: 0 + StringTable: + - '' + - _foo + - '' + - '' +... diff --git a/llvm/tools/llvm-readobj/MachODumper.cpp b/llvm/tools/llvm-readobj/MachODumper.cpp --- a/llvm/tools/llvm-readobj/MachODumper.cpp +++ b/llvm/tools/llvm-readobj/MachODumper.cpp @@ -256,11 +256,14 @@ }; static const EnumEntry MachOSymbolFlags[] = { + { "ThumbDef", 0x8 }, { "ReferencedDynamically", 0x10 }, { "NoDeadStrip", 0x20 }, { "WeakRef", 0x40 }, { "WeakDef", 0x80 }, + { "SymbolResolver", 0x100 }, { "AltEntry", 0x200 }, + { "ColdFunc", 0x400 }, }; static const EnumEntry MachOSymbolTypes[] = { @@ -651,9 +654,9 @@ makeArrayRef(MachOSymbolTypes)); } W.printHex("Section", SectionName, MOSymbol.SectionIndex); - W.printEnum("RefType", static_cast(MOSymbol.Flags & 0xF), + W.printEnum("RefType", static_cast(MOSymbol.Flags & 0x7), makeArrayRef(MachOSymbolRefTypes)); - W.printFlags("Flags", static_cast(MOSymbol.Flags & ~0xF), + W.printFlags("Flags", static_cast(MOSymbol.Flags & ~0x7), makeArrayRef(MachOSymbolFlags)); W.printHex("Value", MOSymbol.Value); }