[lld] r279810 - Implement support for --build-id=uuid switch
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 26 02:55:38 PDT 2016
Author: evgeny777
Date: Fri Aug 26 04:55:37 2016
New Revision: 279810
URL: http://llvm.org/viewvc/llvm-project?rev=279810&view=rev
Log:
Implement support for --build-id=uuid switch
Differential revision: https://reviews.llvm.org/D23349
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/build-id.s
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=279810&r1=279809&r2=279810&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Fri Aug 26 04:55:37 2016
@@ -30,7 +30,7 @@ enum ELFKind {
ELF64BEKind
};
-enum class BuildIdKind { None, Fnv1, Md5, Sha1, Hexstring };
+enum class BuildIdKind { None, Fnv1, Md5, Sha1, Hexstring, Uuid };
enum class UnresolvedPolicy { NoUndef, Error, Warn, Ignore };
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=279810&r1=279809&r2=279810&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Aug 26 04:55:37 2016
@@ -450,6 +450,8 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->BuildId = BuildIdKind::Md5;
} else if (S == "sha1") {
Config->BuildId = BuildIdKind::Sha1;
+ } else if (S == "uuid") {
+ Config->BuildId = BuildIdKind::Uuid;
} else if (S == "none") {
Config->BuildId = BuildIdKind::None;
} else if (S.startswith("0x")) {
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=279810&r1=279809&r2=279810&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Aug 26 04:55:37 2016
@@ -19,7 +19,7 @@
#include "llvm/Support/MD5.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/SHA1.h"
-#include <map>
+#include "llvm/Support/RandomNumberGenerator.h"
using namespace llvm;
using namespace llvm::dwarf;
@@ -1681,6 +1681,12 @@ void BuildIdSha1<ELFT>::writeBuildId(Arr
}
template <class ELFT>
+void BuildIdUuid<ELFT>::writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) {
+ if (getRandomBytes(this->HashBuf, 16))
+ error("entropy source failure");
+}
+
+template <class ELFT>
BuildIdHexstring<ELFT>::BuildIdHexstring()
: BuildIdSection<ELFT>(Config->BuildIdVector.size()) {}
@@ -1994,6 +2000,11 @@ template class BuildIdSha1<ELF32BE>;
template class BuildIdSha1<ELF64LE>;
template class BuildIdSha1<ELF64BE>;
+template class BuildIdUuid<ELF32LE>;
+template class BuildIdUuid<ELF32BE>;
+template class BuildIdUuid<ELF64LE>;
+template class BuildIdUuid<ELF64BE>;
+
template class BuildIdHexstring<ELF32LE>;
template class BuildIdHexstring<ELF32BE>;
template class BuildIdHexstring<ELF64LE>;
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=279810&r1=279809&r2=279810&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Fri Aug 26 04:55:37 2016
@@ -727,6 +727,12 @@ public:
void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
};
+template <class ELFT> class BuildIdUuid final : public BuildIdSection<ELFT> {
+public:
+ BuildIdUuid() : BuildIdSection<ELFT>(16) {}
+ void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
+};
+
template <class ELFT>
class BuildIdHexstring final : public BuildIdSection<ELFT> {
public:
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=279810&r1=279809&r2=279810&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Aug 26 04:55:37 2016
@@ -156,6 +156,8 @@ template <class ELFT> void elf::writeRes
BuildId.reset(new BuildIdMd5<ELFT>);
else if (Config->BuildId == BuildIdKind::Sha1)
BuildId.reset(new BuildIdSha1<ELFT>);
+ else if (Config->BuildId == BuildIdKind::Uuid)
+ BuildId.reset(new BuildIdUuid<ELFT>);
else if (Config->BuildId == BuildIdKind::Hexstring)
BuildId.reset(new BuildIdHexstring<ELFT>);
Modified: lld/trunk/test/ELF/build-id.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/build-id.s?rev=279810&r1=279809&r2=279810&view=diff
==============================================================================
--- lld/trunk/test/ELF/build-id.s (original)
+++ lld/trunk/test/ELF/build-id.s Fri Aug 26 04:55:37 2016
@@ -7,6 +7,8 @@
# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=MD5 %s
# RUN: ld.lld --build-id=sha1 %t -o %t2
# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=SHA1 %s
+# RUN: ld.lld --build-id=uuid %t -o %t2
+# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=UUID %s
# RUN: ld.lld --build-id=0x12345678 %t -o %t2
# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=HEX %s
# RUN: ld.lld %t -o %t2
@@ -31,6 +33,9 @@ _start:
# SHA1: Contents of section .note.gnu.build-id:
# SHA1-NEXT: 04000000 14000000 03000000 474e5500 ............GNU.
+# UUID: Contents of section .note.gnu.build-id:
+# UUID-NEXT: 04000000 10000000 03000000 474e5500 ............GNU.
+
# HEX: Contents of section .note.gnu.build-id:
# HEX-NEXT: 04000000 04000000 03000000 474e5500 ............GNU.
# HEX-NEXT: 12345678
More information about the llvm-commits
mailing list