From 84c0e17e928a3600c786c614861654fded08423e Mon Sep 17 00:00:00 2001
From: Andrew Lenharth <andrewl@lenharth.org>
Date: Fri, 26 Jan 2007 22:28:48 +0000
Subject: [PATCH] Linker should keep sections on globals.  This should
 propagate to mainline if it is correct

llvm-svn: 33554
---
 llvm/lib/Linker/LinkModules.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index 90b45028bc11..0d2e5bb24830 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -456,6 +456,9 @@ static bool LinkGlobals(Module *Dest, Module *Src,
                            SGV->getName(), Dest);
       // Propagate alignment info.
       NewDGV->setAlignment(SGV->getAlignment());
+
+      // Propagate section info.
+      NewDGV->setSection(SGV->getSection());
       
       // If the LLVM runtime renamed the global, but it is an externally visible
       // symbol, DGV must be an existing global with internal linkage.  Rename
@@ -481,6 +484,9 @@ static bool LinkGlobals(Module *Dest, Module *Src,
       // Propagate alignment info.
       NewDGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
 
+      // Propagate section info.
+      NewDGV->setSection(SGV->getSection());
+
       // Make sure to remember this mapping...
       ValueMap.insert(std::make_pair(SGV, NewDGV));
 
@@ -490,6 +496,9 @@ static bool LinkGlobals(Module *Dest, Module *Src,
       // Propagate alignment info.
       DGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
 
+      // Propagate section info.
+      DGV->setSection(SGV->getSection());
+
       // Otherwise, perform the mapping as instructed by GetLinkageResult.  If
       // the types don't match, and if we are to link from the source, nuke DGV
       // and create a new one of the appropriate type.
-- 
GitLab