Skip to content

Commit 922346e

Browse files
committed
[lld-macho] Preserve the size of common symbols
We never noticed this before because the only time the size gets emitted is via the linker map... Reviewed By: #lld-macho, thakis Differential Revision: https://reviews.llvm.org/D135884
1 parent bdd0cec commit 922346e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lld/MachO/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ static void replaceCommonSymbols() {
577577
// FIXME: CommonSymbol should store isReferencedDynamically, noDeadStrip
578578
// and pass them on here.
579579
replaceSymbol<Defined>(
580-
sym, sym->getName(), common->getFile(), isec, /*value=*/0, /*size=*/0,
580+
sym, sym->getName(), common->getFile(), isec, /*value=*/0, common->size,
581581
/*isWeakDef=*/false, /*isExternal=*/true, common->privateExtern,
582582
/*includeInSymtab=*/true, /*isThumb=*/false,
583583
/*isReferencedDynamically=*/false, /*noDeadStrip=*/false);

lld/test/MachO/dead-strip.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
# MAP: _main
5050
# MAP-LABEL: Dead Stripped Symbols
51-
# MAP: <<dead>> 0x00000000 [ 1] _unref_com
51+
# MAP: <<dead>> 0x00000001 [ 1] _unref_com
5252
# MAP: <<dead>> 0x00000008 [ 1] _unref_data
5353
# MAP: <<dead>> 0x00000006 [ 1] _unref_extern
5454
# MAP: <<dead>> 0x00000001 [ 1] _unref_local

lld/test/MachO/map-file.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# CHECK-NEXT: # Address Size File Name
4141
# CHECK-NEXT: 0x[[#%X,MAIN]] 0x00000001 [ 1] _main
4242
# CHECK-NEXT: 0x[[#%X,FOO]] 0x00000000 [ 2] _foo
43-
# CHECK-NEXT: 0x[[#%X,NUMBER]] 0x00000000 [ 1] _number
43+
# CHECK-NEXT: 0x[[#%X,NUMBER]] 0x00000001 [ 1] _number
4444

4545
# RUN: %lld -map %t/c-string-literal-map %t/c-string-literal.o -o %t/c-string-literal-out
4646
# RUN: FileCheck --check-prefix=CSTRING %s < %t/c-string-literal-map

0 commit comments

Comments
 (0)