[lld] 922346e - [lld-macho] Preserve the size of common symbols
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 13 13:45:03 PDT 2022
Author: Jez Ng
Date: 2022-10-13T16:44:33-04:00
New Revision: 922346ef052f05cfef79b184740217b75647fa34
URL: https://github.com/llvm/llvm-project/commit/922346ef052f05cfef79b184740217b75647fa34
DIFF: https://github.com/llvm/llvm-project/commit/922346ef052f05cfef79b184740217b75647fa34.diff
LOG: [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
Added:
Modified:
lld/MachO/Driver.cpp
lld/test/MachO/dead-strip.s
lld/test/MachO/map-file.s
Removed:
################################################################################
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 8ef2a36ed942..9875c6f29a60 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -577,7 +577,7 @@ static void replaceCommonSymbols() {
// FIXME: CommonSymbol should store isReferencedDynamically, noDeadStrip
// and pass them on here.
replaceSymbol<Defined>(
- sym, sym->getName(), common->getFile(), isec, /*value=*/0, /*size=*/0,
+ sym, sym->getName(), common->getFile(), isec, /*value=*/0, common->size,
/*isWeakDef=*/false, /*isExternal=*/true, common->privateExtern,
/*includeInSymtab=*/true, /*isThumb=*/false,
/*isReferencedDynamically=*/false, /*noDeadStrip=*/false);
diff --git a/lld/test/MachO/dead-strip.s b/lld/test/MachO/dead-strip.s
index e2de6198e8ab..a9892fdd94b1 100644
--- a/lld/test/MachO/dead-strip.s
+++ b/lld/test/MachO/dead-strip.s
@@ -48,7 +48,7 @@
# MAP: _main
# MAP-LABEL: Dead Stripped Symbols
-# MAP: <<dead>> 0x00000000 [ 1] _unref_com
+# MAP: <<dead>> 0x00000001 [ 1] _unref_com
# MAP: <<dead>> 0x00000008 [ 1] _unref_data
# MAP: <<dead>> 0x00000006 [ 1] _unref_extern
# MAP: <<dead>> 0x00000001 [ 1] _unref_local
diff --git a/lld/test/MachO/map-file.s b/lld/test/MachO/map-file.s
index 759a9ba445f8..f1c8660f9d5a 100644
--- a/lld/test/MachO/map-file.s
+++ b/lld/test/MachO/map-file.s
@@ -40,7 +40,7 @@
# CHECK-NEXT: # Address Size File Name
# CHECK-NEXT: 0x[[#%X,MAIN]] 0x00000001 [ 1] _main
# CHECK-NEXT: 0x[[#%X,FOO]] 0x00000000 [ 2] _foo
-# CHECK-NEXT: 0x[[#%X,NUMBER]] 0x00000000 [ 1] _number
+# CHECK-NEXT: 0x[[#%X,NUMBER]] 0x00000001 [ 1] _number
# RUN: %lld -map %t/c-string-literal-map %t/c-string-literal.o -o %t/c-string-literal-out
# RUN: FileCheck --check-prefix=CSTRING %s < %t/c-string-literal-map
More information about the llvm-commits
mailing list