[lld] r221442 - [Mips] Take into account that PIC code is inherently CPIC
Simon Atanasyan
simon at atanasyan.com
Wed Nov 5 23:07:29 PST 2014
Author: atanasyan
Date: Thu Nov 6 01:07:29 2014
New Revision: 221442
URL: http://llvm.org/viewvc/llvm-project?rev=221442&view=rev
Log:
[Mips] Take into account that PIC code is inherently CPIC
Follow-up to r221439.
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFlagsMerger.cpp
lld/trunk/test/elf/Mips/e-flags-merge-3.test
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFlagsMerger.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFlagsMerger.cpp?rev=221442&r1=221441&r2=221442&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFlagsMerger.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFlagsMerger.cpp Thu Nov 6 01:07:29 2014
@@ -48,6 +48,11 @@ std::error_code MipsELFFlagsMerger::merg
if (newFlags & llvm::ELF::EF_MIPS_ARCH_ASE_M16)
return make_dynamic_error_code(Twine("Unsupported extension: MIPS16"));
+ // PIC code is inherently CPIC and may not set CPIC flag explicitly.
+ // Ensure that this flag will exist in the linked file.
+ if (newFlags & llvm::ELF::EF_MIPS_PIC)
+ newFlags |= llvm::ELF::EF_MIPS_CPIC;
+
std::lock_guard<std::mutex> lock(_mutex);
// If the old set of flags is empty, use the new one as a result.
@@ -64,10 +69,10 @@ std::error_code MipsELFFlagsMerger::merg
if ((newPic != 0) != (oldPic != 0))
llvm::errs() << "lld warning: linking abicalls and non-abicalls files\n";
- if (newPic != 0)
- _flags |= llvm::ELF::EF_MIPS_CPIC;
if (!(newPic & llvm::ELF::EF_MIPS_PIC))
_flags &= ~llvm::ELF::EF_MIPS_PIC;
+ if (newPic)
+ _flags |= llvm::ELF::EF_MIPS_CPIC;
// Check mixing -mnan=2008 / -mnan=legacy modules.
if ((newFlags & llvm::ELF::EF_MIPS_NAN2008) !=
Modified: lld/trunk/test/elf/Mips/e-flags-merge-3.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/e-flags-merge-3.test?rev=221442&r1=221441&r2=221442&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/e-flags-merge-3.test (original)
+++ lld/trunk/test/elf/Mips/e-flags-merge-3.test Thu Nov 6 01:07:29 2014
@@ -23,9 +23,10 @@
# ABI-CALLS-WARN: lld warning: linking abicalls and non-abicalls files
-# ABI-CALLS1: Flags [ (0x50001000)
+# ABI-CALLS1: Flags [ (0x50001004)
# ABI-CALLS1-NEXT: EF_MIPS_ABI_O32 (0x1000)
# ABI-CALLS1-NEXT: EF_MIPS_ARCH_32 (0x50000000)
+# ABI-CALLS1-NEXT: EF_MIPS_CPIC (0x4)
# ABI-CALLS1-NEXT: ]
# ABI-CALLS2: Flags [ (0x50001004)
More information about the llvm-commits
mailing list