Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Unified Diff: llvm-trunk/lib/MC/ELFObjectWriter.cpp

Issue 6538110: Cherry pick -r124899 from llvm root (Closed)
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « llvm-trunk/include/llvm/Support/ELF.h ('k') | llvm-trunk/test/MC/ARM/elf-eflags-eabi.s » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: llvm-trunk/lib/MC/ELFObjectWriter.cpp
===================================================================
--- a/llvm-trunk/lib/MC/ELFObjectWriter.cpp
+++ b/llvm-trunk/lib/MC/ELFObjectWriter.cpp
@@ -276,6 +276,20 @@
virtual void WriteHeader(uint64_t SectionDataSize, unsigned NumberOfSections);
+ /// Default e_flags = 0
+ virtual void WriteEFlags() {
+ // @LOCALMOD-BEGIN
robertm 2011/02/23 15:08:58 I am confused which way are you cherry picking. Wh
jasonwkim 2011/02/23 15:28:17 Because our code uses EF_NACL_ALIGN_32 which the u
+ switch (TargetObjectWriter->getOSType()) {
+ case Triple::NativeClient:
+ Write32(ELF::EF_NACL_ALIGN_32);
+ break;
+ default:
+ Write32(0); // e_flags = whatever the target wants
+ break;
+ }
+ // @LOCALMOD-END
+ }
+
virtual void WriteSymbolEntry(MCDataFragment *SymtabF, MCDataFragment *ShndxF,
uint64_t name, uint8_t info,
uint64_t value, uint64_t size,
@@ -387,11 +401,16 @@
class ARMELFObjectWriter : public ELFObjectWriter {
public:
+ // FIXME: MCAssembler can't yet return the Subtarget,
+ enum { DefaultEABIVersion = 0x05000000U };
+
ARMELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_ostream &_OS,
bool IsLittleEndian);
virtual ~ARMELFObjectWriter();
+
+ virtual void WriteEFlags();
protected:
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel, bool IsRelocWithSymbol,
@@ -474,16 +493,8 @@
WriteWord(SectionDataSize + (is64Bit() ? sizeof(ELF::Elf64_Ehdr) :
sizeof(ELF::Elf32_Ehdr))); // e_shoff = sec hdr table off in bytes
- // @LOCALMOD-BEGIN
- switch (TargetObjectWriter->getOSType()) {
- case Triple::NativeClient:
- Write32(ELF::EF_NACL_ALIGN_32);
- break;
- default:
- Write32(0); // e_flags = whatever the target wants
- break;
- }
- // @LOCALMOD-END
+ // e_flags = whatever the target wants
+ WriteEFlags();
// e_ehsize = ELF header size
Write16(is64Bit() ? sizeof(ELF::Elf64_Ehdr) : sizeof(ELF::Elf32_Ehdr));
@@ -1495,7 +1506,6 @@
/// START OF SUBCLASSES for ELFObjectWriter
//===- ARMELFObjectWriter -------------------------------------------===//
-
ARMELFObjectWriter::ARMELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_ostream &_OS,
bool IsLittleEndian)
@@ -1505,6 +1515,20 @@
ARMELFObjectWriter::~ARMELFObjectWriter()
{}
+// FIXME: get the real EABI Version from the Triple.
+void ARMELFObjectWriter::WriteEFlags() {
+ // @LOCALMOD-BEGIN
+ unsigned e_flag = ELF::EF_ARM_EABIMASK & DefaultEABIVersion;
+ switch (TargetObjectWriter->getOSType()) {
+ case Triple::NativeClient:
+ e_flag |= ELF::EF_NACL_ALIGN_32;
+ break;
+ default: break;
+ }
+ Write32(e_flag);
+ // @LOCALMOD-END
+}
+
unsigned ARMELFObjectWriter::GetRelocType(const MCValue &Target,
const MCFixup &Fixup,
bool IsPCRel,
« no previous file with comments | « llvm-trunk/include/llvm/Support/ELF.h ('k') | llvm-trunk/test/MC/ARM/elf-eflags-eabi.s » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698