diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 3b01631d123a..bde48972b019 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -260,6 +260,7 @@ template void SymbolTableSection::writeTo(uint8_t *Buf) { uint8_t Type = InputSym->getType(); uint8_t Binding = InputSym->getBinding(); ESym->setBindingAndType(Binding, Type); + ESym->st_size = InputSym->st_size; } if (Section) { diff --git a/lld/test/elf2/symbols.s b/lld/test/elf2/symbols.s index e2b299626344..be0661d74137 100644 --- a/lld/test/elf2/symbols.s +++ b/lld/test/elf2/symbols.s @@ -25,6 +25,7 @@ zed2: .section foobar,"a",@nobits,unique,2 .globl zed3 +.size zed3, 4 zed3: // CHECK: Name: .text @@ -64,7 +65,7 @@ zed3: // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: zed3 // CHECK-NEXT: Value: 0x100C -// CHECK-NEXT: Size: 0 +// CHECK-NEXT: Size: 4 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0