diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index ed1ae9397317..91a0bf5abaa4 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -330,6 +330,7 @@ template void SymbolTableSection::writeTo(uint8_t *Buf) { uint8_t Binding = InputSym->getBinding(); ESym->setBindingAndType(Binding, Type); ESym->st_size = InputSym->st_size; + ESym->st_other = InputSym->st_other; if (InputSym->isAbsolute()) { ESym->st_shndx = SHN_ABS; ESym->st_value = InputSym->st_value; diff --git a/lld/test/elf2/symbols.s b/lld/test/elf2/symbols.s index 603739b8721b..cfb36a2d6205 100644 --- a/lld/test/elf2/symbols.s +++ b/lld/test/elf2/symbols.s @@ -33,6 +33,10 @@ abs = 0x123 .comm common,4,4 +.global protected +.protected protected +protected: + // CHECK: Name: .text // CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ @@ -123,6 +127,15 @@ abs = 0x123 // CHECK-NEXT: Section: foobar // CHECK-NEXT: } // CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: protected +// CHECK-NEXT: Value: 0x1010 +// CHECK-NEXT: Size: 0 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other: 3 +// CHECK-NEXT: Section: foobar +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { // CHECK-NEXT: Name: zed3 // CHECK-NEXT: Value: 0x1010 // CHECK-NEXT: Size: 4