aboutsummaryrefslogtreecommitdiffstats
path: root/tools/gold
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-04-23 16:57:46 -0700
committerStephen Hines <srhines@google.com>2014-04-24 15:53:16 -0700
commit36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch)
treee6cfb69fbbd937f450eeb83bfb83b9da3b01275a /tools/gold
parent69a8640022b04415ae9fac62f8ab090601d8f889 (diff)
downloadexternal_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'tools/gold')
-rw-r--r--tools/gold/CMakeLists.txt30
-rw-r--r--tools/gold/gold-plugin.cpp14
2 files changed, 14 insertions, 30 deletions
diff --git a/tools/gold/CMakeLists.txt b/tools/gold/CMakeLists.txt
index 2cc132f..07a1e28 100644
--- a/tools/gold/CMakeLists.txt
+++ b/tools/gold/CMakeLists.txt
@@ -1,6 +1,8 @@
set(LLVM_BINUTILS_INCDIR "" CACHE PATH
"PATH to binutils/include containing plugin-api.h for gold plugin.")
+set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/gold.exports)
+
if( NOT LLVM_BINUTILS_INCDIR )
# Nothing to say.
elseif( NOT EXISTS "${LLVM_BINUTILS_INCDIR}/plugin-api.h" )
@@ -18,29 +20,7 @@ else()
gold-plugin.cpp
)
- # Makefile.rules contains a special cases for OpenBSD, Darwin and
- # Windows. We restrict ourselves to Linux for the time being.
- set(srcexp ${CMAKE_CURRENT_SOURCE_DIR}/gold.exports)
- add_custom_command(OUTPUT exportsfile
- COMMAND echo "{" > exportsfile
- COMMAND grep -q "\\<" ${srcexp} && echo " global:" >> exportsfile || :
- COMMAND sed -e "s/$/;/" -e "s/^/ /" < ${srcexp} >> exportsfile
- COMMAND echo " local: *;" >> exportsfile
- COMMAND echo "};" >> exportsfile
- DEPENDS ${srcexp}
- VERBATIM
- COMMENT "Creating export file for gold plugin")
- add_custom_target(gold_exports DEPENDS exportsfile)
- set_property(DIRECTORY APPEND
- PROPERTY ADDITIONAL_MAKE_CLEAN_FILES exportsfile)
-
- # Force re-linking when the exports file changes. Actually, it
- # forces recompilation of gold-plugin.cpp. The LINK_DEPENDS target
- # property only works for makefile-based generators.
- set_property(SOURCE gold-plugin.cpp APPEND PROPERTY
- OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/exportsfile)
-
- target_link_libraries(LLVMgold LTO
- -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/exportsfile)
- add_dependencies(LLVMgold gold_exports)
+ target_link_libraries(LLVMgold ${cmake_2_8_12_PRIVATE} LTO)
+
endif()
+
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp
index 0e3bad2..4726d82 100644
--- a/tools/gold/gold-plugin.cpp
+++ b/tools/gold/gold-plugin.cpp
@@ -13,10 +13,8 @@
//===----------------------------------------------------------------------===//
#include "llvm/Config/config.h" // plugin-api.h requires HAVE_STDINT_H
-#include "plugin-api.h"
#include "llvm-c/lto.h"
#include "llvm/ADT/StringSet.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -29,6 +27,7 @@
#include <cstring>
#include <fstream>
#include <list>
+#include <plugin-api.h>
#include <vector>
// Support Windows/MinGW crazyness.
@@ -38,6 +37,12 @@
# define read _read
#endif
+#ifndef LDPO_PIE
+// FIXME: remove this declaration when we stop maintaining Ubuntu Quantal and
+// Precise and Debian Wheezy (binutils 2.23 is required)
+# define LDPO_PIE 3
+#endif
+
using namespace llvm;
namespace {
@@ -153,8 +158,7 @@ ld_plugin_status onload(ld_plugin_tv *tv) {
switch (tv->tv_u.tv_val) {
case LDPO_REL: // .o
case LDPO_DYN: // .so
- // FIXME: Replace 3 with LDPO_PIE once that is in a released binutils.
- case 3: // position independent executable
+ case LDPO_PIE: // position independent executable
output_type = LTO_CODEGEN_PIC_MODEL_DYNAMIC;
break;
case LDPO_EXEC: // .exe
@@ -241,7 +245,7 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
int *claimed) {
lto_module_t M;
const void *view;
- OwningPtr<MemoryBuffer> buffer;
+ std::unique_ptr<MemoryBuffer> buffer;
if (get_view) {
if (get_view(file->handle, &view) != LDPS_OK) {
(*message)(LDPL_ERROR, "Failed to get a view of %s", file->name);