Home | History | Annotate | Download | only in mclinker
      1 From d4d813fa1fffb1ece1630a1fbc8bc9339dd4b3ae Mon Sep 17 00:00:00 2001
      2 From: Andrew Hsieh <andrewhsieh (a] google.com>
      3 Date: Wed, 19 Jun 2013 15:09:04 -0700
      4 Subject: [PATCH 1/2] Compile against llvm-3.3
      5 
      6 Change-Id: I3e34b391e5effb173dc1a08c75fae5e9ba530bec
      7 ---
      8  lib/Fragment/FragmentLinker.cpp           |  2 +-
      9  lib/LD/ELFReader.cpp                      | 36 +++++++++++++++----------------
     10  lib/LD/GNUArchiveReader.cpp               |  4 ++--
     11  lib/LD/RelocationFactory.cpp              |  2 +-
     12  lib/Target/GNULDBackend.cpp               |  8 +++----
     13  tools/llvm-mcld/llvm-mcld.cpp             |  3 ++-
     14  tools/mcld/lib/Support/Initialization.cpp |  3 ++-
     15  7 files changed, 30 insertions(+), 28 deletions(-)
     16 
     17 diff --git a/lib/Fragment/FragmentLinker.cpp b/lib/Fragment/FragmentLinker.cpp
     18 index 2a183b2..5a4b53f 100644
     19 --- a/lib/Fragment/FragmentLinker.cpp
     20 +++ b/lib/Fragment/FragmentLinker.cpp
     21 @@ -231,7 +231,7 @@ void FragmentLinker::writeRelocationResult(Relocation& pReloc, uint8_t* pOutput)
     22  
     23    uint8_t* target_addr = pOutput + out_offset;
     24    // byte swapping if target and host has different endian, and then write back
     25 -  if(llvm::sys::isLittleEndianHost() != m_Config.targets().isLittleEndian()) {
     26 +  if(llvm::sys::IsLittleEndianHost != m_Config.targets().isLittleEndian()) {
     27       uint64_t tmp_data = 0;
     28  
     29       switch(pReloc.size(*m_Backend.getRelocator())) {
     30 diff --git a/lib/LD/ELFReader.cpp b/lib/LD/ELFReader.cpp
     31 index 3807834..15d4862 100644
     32 --- a/lib/LD/ELFReader.cpp
     33 +++ b/lib/LD/ELFReader.cpp
     34 @@ -91,7 +91,7 @@ bool ELFReader<32, true>::readSymbols(Input& pInput,
     35      st_info  = symtab[idx].st_info;
     36      st_other = symtab[idx].st_other;
     37  
     38 -    if (llvm::sys::isLittleEndianHost()) {
     39 +    if (llvm::sys::IsLittleEndianHost) {
     40        st_name  = symtab[idx].st_name;
     41        st_value = symtab[idx].st_value;
     42        st_size  = symtab[idx].st_size;
     43 @@ -279,7 +279,7 @@ bool ELFReader<32, true>::isMyMachine(void* pELFHeader) const
     44    llvm::ELF::Elf32_Ehdr* hdr =
     45                            reinterpret_cast<llvm::ELF::Elf32_Ehdr*>(pELFHeader);
     46  
     47 -  if (llvm::sys::isLittleEndianHost())
     48 +  if (llvm::sys::IsLittleEndianHost)
     49      return (hdr->e_machine == target().getInfo().machine());
     50    return (mcld::bswap16(hdr->e_machine) == target().getInfo().machine());
     51  }
     52 @@ -290,7 +290,7 @@ Input::Type ELFReader<32, true>::fileType(void* pELFHeader) const
     53    llvm::ELF::Elf32_Ehdr* hdr =
     54                            reinterpret_cast<llvm::ELF::Elf32_Ehdr*>(pELFHeader);
     55    uint32_t type = 0x0;
     56 -  if (llvm::sys::isLittleEndianHost())
     57 +  if (llvm::sys::IsLittleEndianHost)
     58      type = hdr->e_type;
     59    else
     60      type = mcld::bswap16(hdr->e_type);
     61 @@ -322,7 +322,7 @@ ELFReader<32, true>::readSectionHeaders(Input& pInput, void* pELFHeader) const
     62    uint32_t shnum     = 0x0;
     63    uint32_t shstrtab  = 0x0;
     64  
     65 -  if (llvm::sys::isLittleEndianHost()) {
     66 +  if (llvm::sys::IsLittleEndianHost) {
     67      shoff     = ehdr->e_shoff;
     68      shentsize = ehdr->e_shentsize;
     69      shnum     = ehdr->e_shnum;
     70 @@ -356,7 +356,7 @@ ELFReader<32, true>::readSectionHeaders(Input& pInput, void* pELFHeader) const
     71                                              shentsize);
     72      shdr = reinterpret_cast<llvm::ELF::Elf32_Shdr*>(shdr_region->start());
     73  
     74 -    if (llvm::sys::isLittleEndianHost()) {
     75 +    if (llvm::sys::IsLittleEndianHost) {
     76        sh_size = shdr->sh_size;
     77        sh_link = shdr->sh_link;
     78      }
     79 @@ -381,7 +381,7 @@ ELFReader<32, true>::readSectionHeaders(Input& pInput, void* pELFHeader) const
     80  
     81    // get .shstrtab first
     82    shdr = &shdrTab[shstrtab];
     83 -  if (llvm::sys::isLittleEndianHost()) {
     84 +  if (llvm::sys::IsLittleEndianHost) {
     85      sh_offset = shdr->sh_offset;
     86      sh_size   = shdr->sh_size;
     87    }
     88 @@ -399,7 +399,7 @@ ELFReader<32, true>::readSectionHeaders(Input& pInput, void* pELFHeader) const
     89  
     90    // create all LDSections, including first NULL section.
     91    for (size_t idx = 0; idx < shnum; ++idx) {
     92 -    if (llvm::sys::isLittleEndianHost()) {
     93 +    if (llvm::sys::IsLittleEndianHost) {
     94        sh_name      = shdrTab[idx].sh_name;
     95        sh_type      = shdrTab[idx].sh_type;
     96        sh_flags     = shdrTab[idx].sh_flags;
     97 @@ -479,7 +479,7 @@ ResolveInfo* ELFReader<32, true>::readSignature(Input& pInput,
     98    uint16_t st_shndx = 0x0;
     99    st_info  = entry->st_info;
    100    st_other = entry->st_other;
    101 -  if (llvm::sys::isLittleEndianHost()) {
    102 +  if (llvm::sys::IsLittleEndianHost) {
    103      st_name  = entry->st_name;
    104      st_shndx = entry->st_shndx;
    105    }
    106 @@ -541,7 +541,7 @@ bool ELFReader<32, true>::readDynamic(Input& pInput) const
    107      llvm::ELF::Elf32_Sword d_tag = 0x0;
    108      llvm::ELF::Elf32_Word d_val = 0x0;
    109  
    110 -    if (llvm::sys::isLittleEndianHost()) {
    111 +    if (llvm::sys::IsLittleEndianHost) {
    112        d_tag = dynamic[idx].d_tag;
    113        d_val = dynamic[idx].d_un.d_val;
    114      } else {
    115 @@ -636,7 +636,7 @@ bool ELFReader<64, true>::readSymbols(Input& pInput,
    116      st_info  = symtab[idx].st_info;
    117      st_other = symtab[idx].st_other;
    118  
    119 -    if (llvm::sys::isLittleEndianHost()) {
    120 +    if (llvm::sys::IsLittleEndianHost) {
    121        st_name  = symtab[idx].st_name;
    122        st_value = symtab[idx].st_value;
    123        st_size  = symtab[idx].st_size;
    124 @@ -820,7 +820,7 @@ bool ELFReader<64, true>::isMyMachine(void* pELFHeader) const
    125    llvm::ELF::Elf64_Ehdr* hdr =
    126                            reinterpret_cast<llvm::ELF::Elf64_Ehdr*>(pELFHeader);
    127  
    128 -  if (llvm::sys::isLittleEndianHost())
    129 +  if (llvm::sys::IsLittleEndianHost)
    130      return (hdr->e_machine == target().getInfo().machine());
    131    return (mcld::bswap16(hdr->e_machine) == target().getInfo().machine());
    132  }
    133 @@ -831,7 +831,7 @@ Input::Type ELFReader<64, true>::fileType(void* pELFHeader) const
    134    llvm::ELF::Elf64_Ehdr* hdr =
    135                            reinterpret_cast<llvm::ELF::Elf64_Ehdr*>(pELFHeader);
    136    uint32_t type = 0x0;
    137 -  if (llvm::sys::isLittleEndianHost())
    138 +  if (llvm::sys::IsLittleEndianHost)
    139      type = hdr->e_type;
    140    else
    141      type = mcld::bswap16(hdr->e_type);
    142 @@ -863,7 +863,7 @@ ELFReader<64, true>::readSectionHeaders(Input& pInput, void* pELFHeader) const
    143    uint32_t shnum     = 0x0;
    144    uint32_t shstrtab  = 0x0;
    145  
    146 -  if (llvm::sys::isLittleEndianHost()) {
    147 +  if (llvm::sys::IsLittleEndianHost) {
    148      shoff     = ehdr->e_shoff;
    149      shentsize = ehdr->e_shentsize;
    150      shnum     = ehdr->e_shnum;
    151 @@ -897,7 +897,7 @@ ELFReader<64, true>::readSectionHeaders(Input& pInput, void* pELFHeader) const
    152                                              shentsize);
    153      shdr = reinterpret_cast<llvm::ELF::Elf64_Shdr*>(shdr_region->start());
    154  
    155 -    if (llvm::sys::isLittleEndianHost()) {
    156 +    if (llvm::sys::IsLittleEndianHost) {
    157        sh_size = shdr->sh_size;
    158        sh_link = shdr->sh_link;
    159      }
    160 @@ -922,7 +922,7 @@ ELFReader<64, true>::readSectionHeaders(Input& pInput, void* pELFHeader) const
    161  
    162    // get .shstrtab first
    163    shdr = &shdrTab[shstrtab];
    164 -  if (llvm::sys::isLittleEndianHost()) {
    165 +  if (llvm::sys::IsLittleEndianHost) {
    166      sh_offset = shdr->sh_offset;
    167      sh_size   = shdr->sh_size;
    168    }
    169 @@ -940,7 +940,7 @@ ELFReader<64, true>::readSectionHeaders(Input& pInput, void* pELFHeader) const
    170  
    171    // create all LDSections, including first NULL section.
    172    for (size_t idx = 0; idx < shnum; ++idx) {
    173 -    if (llvm::sys::isLittleEndianHost()) {
    174 +    if (llvm::sys::IsLittleEndianHost) {
    175        sh_name      = shdrTab[idx].sh_name;
    176        sh_type      = shdrTab[idx].sh_type;
    177        sh_flags     = shdrTab[idx].sh_flags;
    178 @@ -1020,7 +1020,7 @@ ResolveInfo* ELFReader<64, true>::readSignature(Input& pInput,
    179    uint16_t st_shndx = 0x0;
    180    st_info  = entry->st_info;
    181    st_other = entry->st_other;
    182 -  if (llvm::sys::isLittleEndianHost()) {
    183 +  if (llvm::sys::IsLittleEndianHost) {
    184      st_name  = entry->st_name;
    185      st_shndx = entry->st_shndx;
    186    }
    187 @@ -1082,7 +1082,7 @@ bool ELFReader<64, true>::readDynamic(Input& pInput) const
    188      llvm::ELF::Elf64_Sxword d_tag = 0x0;
    189      llvm::ELF::Elf64_Xword d_val = 0x0;
    190  
    191 -    if (llvm::sys::isLittleEndianHost()) {
    192 +    if (llvm::sys::IsLittleEndianHost) {
    193        d_tag = dynamic[idx].d_tag;
    194        d_val = dynamic[idx].d_un.d_val;
    195      } else {
    196 diff --git a/lib/LD/GNUArchiveReader.cpp b/lib/LD/GNUArchiveReader.cpp
    197 index 6324824..e391b20 100644
    198 --- a/lib/LD/GNUArchiveReader.cpp
    199 +++ b/lib/LD/GNUArchiveReader.cpp
    200 @@ -265,7 +265,7 @@ bool GNUArchiveReader::readSymbolTable(Archive& pArchive)
    201  
    202      // read the number of symbols
    203      uint32_t number = 0;
    204 -    if (llvm::sys::isLittleEndianHost())
    205 +    if (llvm::sys::IsLittleEndianHost)
    206        number = mcld::bswap32(*data);
    207      else
    208        number = *data;
    209 @@ -276,7 +276,7 @@ bool GNUArchiveReader::readSymbolTable(Archive& pArchive)
    210  
    211      // add the archive symbols
    212      for (uint32_t i = 0; i < number; ++i) {
    213 -      if (llvm::sys::isLittleEndianHost())
    214 +      if (llvm::sys::IsLittleEndianHost)
    215          pArchive.addSymbol(name, mcld::bswap32(*data));
    216        else
    217          pArchive.addSymbol(name, *data);
    218 diff --git a/lib/LD/RelocationFactory.cpp b/lib/LD/RelocationFactory.cpp
    219 index 8a065a8..bb56cdd 100644
    220 --- a/lib/LD/RelocationFactory.cpp
    221 +++ b/lib/LD/RelocationFactory.cpp
    222 @@ -45,7 +45,7 @@ Relocation* RelocationFactory::produce(RelocationFactory::Type pType,
    223    DWord target_data = 0;
    224  
    225    // byte swapping if the host and target have different endian
    226 -  if(llvm::sys::isLittleEndianHost() != m_pConfig->targets().isLittleEndian()) {
    227 +  if(llvm::sys::IsLittleEndianHost != m_pConfig->targets().isLittleEndian()) {
    228       uint32_t tmp_data;
    229  
    230       switch (m_pConfig->targets().bitclass()) {
    231 diff --git a/lib/Target/GNULDBackend.cpp b/lib/Target/GNULDBackend.cpp
    232 index aa2d386..274fd7b 100644
    233 --- a/lib/Target/GNULDBackend.cpp
    234 +++ b/lib/Target/GNULDBackend.cpp
    235 @@ -1679,7 +1679,7 @@ bool GNULDBackend::readRelocation(const llvm::ELF::Elf32_Rel& pRel,
    236                                    uint32_t& pOffset) const
    237  {
    238    uint32_t r_info = 0x0;
    239 -  if (llvm::sys::isLittleEndianHost()) {
    240 +  if (llvm::sys::IsLittleEndianHost) {
    241      pOffset = pRel.r_offset;
    242      r_info  = pRel.r_info;
    243    }
    244 @@ -1701,7 +1701,7 @@ bool GNULDBackend::readRelocation(const llvm::ELF::Elf32_Rela& pRel,
    245                                    int32_t& pAddend) const
    246  {
    247    uint32_t r_info   = 0x0;
    248 -  if (llvm::sys::isLittleEndianHost()) {
    249 +  if (llvm::sys::IsLittleEndianHost) {
    250      pOffset = pRel.r_offset;
    251      r_info  = pRel.r_info;
    252      pAddend = pRel.r_addend;
    253 @@ -1724,7 +1724,7 @@ bool GNULDBackend::readRelocation(const llvm::ELF::Elf64_Rel& pRel,
    254                                uint64_t& pOffset) const
    255  {
    256    uint64_t r_info = 0x0;
    257 -  if (llvm::sys::isLittleEndianHost()) {
    258 +  if (llvm::sys::IsLittleEndianHost) {
    259      pOffset = pRel.r_offset;
    260      r_info  = pRel.r_info;
    261    }
    262 @@ -1746,7 +1746,7 @@ bool GNULDBackend::readRelocation(const llvm::ELF::Elf64_Rela& pRel,
    263                                int64_t& pAddend) const
    264  {
    265    uint64_t r_info = 0x0;
    266 -  if (llvm::sys::isLittleEndianHost()) {
    267 +  if (llvm::sys::IsLittleEndianHost) {
    268      pOffset = pRel.r_offset;
    269      r_info  = pRel.r_info;
    270      pAddend = pRel.r_addend;
    271 diff --git a/tools/llvm-mcld/llvm-mcld.cpp b/tools/llvm-mcld/llvm-mcld.cpp
    272 index 2f356b3..6f66c4a 100644
    273 --- a/tools/llvm-mcld/llvm-mcld.cpp
    274 +++ b/tools/llvm-mcld/llvm-mcld.cpp
    275 @@ -36,13 +36,14 @@
    276  #include <llvm/Support/Debug.h>
    277  #include <llvm/Support/FormattedStream.h>
    278  #include <llvm/Support/Host.h>
    279 -#include <llvm/Support/IRReader.h>
    280 +#include <llvm/IRReader/IRReader.h>
    281  #include <llvm/Support/ManagedStatic.h>
    282  #include <llvm/Support/Signals.h>
    283  #include <llvm/Support/TargetRegistry.h>
    284  #include <llvm/Support/TargetSelect.h>
    285  #include <llvm/Support/Process.h>
    286  #include <llvm/Target/TargetMachine.h>
    287 +#include <llvm/Support/SourceMgr.h>
    288  
    289  #if defined(HAVE_UNISTD_H)
    290  # include <unistd.h>
    291 diff --git a/tools/mcld/lib/Support/Initialization.cpp b/tools/mcld/lib/Support/Initialization.cpp
    292 index 71bd57d..90cb574 100644
    293 --- a/tools/mcld/lib/Support/Initialization.cpp
    294 +++ b/tools/mcld/lib/Support/Initialization.cpp
    295 @@ -22,7 +22,8 @@
    296  
    297  namespace {
    298  
    299 -void llvm_error_handler(void *pUserData, const std::string &pMessage) {
    300 +void llvm_error_handler(void *pUserData, const std::string &pMessage,
    301 +                        bool gen_crash_diag = true) {
    302    ALOGE("%s", pMessage.c_str());
    303    ::exit(1);
    304  }
    305 -- 
    306 1.8.3
    307 
    308