summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-objcopy/CopyConfig.cpp8
-rw-r--r--llvm/tools/llvm-objcopy/CopyConfig.h1
-rw-r--r--llvm/tools/llvm-objcopy/ObjcopyOpts.td16
-rw-r--r--llvm/tools/llvm-objcopy/StripOpts.td16
-rw-r--r--llvm/tools/llvm-objcopy/llvm-objcopy.cpp8
5 files changed, 45 insertions, 4 deletions
diff --git a/llvm/tools/llvm-objcopy/CopyConfig.cpp b/llvm/tools/llvm-objcopy/CopyConfig.cpp
index 24c72de8882..8df93efa785 100644
--- a/llvm/tools/llvm-objcopy/CopyConfig.cpp
+++ b/llvm/tools/llvm-objcopy/CopyConfig.cpp
@@ -343,6 +343,10 @@ DriverConfig parseObjcopyOptions(ArrayRef<const char *> ArgsArr) {
for (auto Arg : InputArgs.filtered(OBJCOPY_keep_symbol))
Config.SymbolsToKeep.push_back(Arg->getValue());
+ Config.DeterministicArchives = InputArgs.hasFlag(
+ OBJCOPY_enable_deterministic_archives,
+ OBJCOPY_disable_deterministic_archives, /*default=*/true);
+
Config.PreserveDates = InputArgs.hasArg(OBJCOPY_preserve_dates);
if (Config.DecompressDebugSections &&
@@ -411,6 +415,10 @@ DriverConfig parseStripOptions(ArrayRef<const char *> ArgsArr) {
for (auto Arg : InputArgs.filtered(STRIP_keep_symbol))
Config.SymbolsToKeep.push_back(Arg->getValue());
+ Config.DeterministicArchives =
+ InputArgs.hasFlag(STRIP_enable_deterministic_archives,
+ STRIP_disable_deterministic_archives, /*default=*/true);
+
Config.PreserveDates = InputArgs.hasArg(STRIP_preserve_dates);
DriverConfig DC;
diff --git a/llvm/tools/llvm-objcopy/CopyConfig.h b/llvm/tools/llvm-objcopy/CopyConfig.h
index 203432a11a6..7ebe2a072bb 100644
--- a/llvm/tools/llvm-objcopy/CopyConfig.h
+++ b/llvm/tools/llvm-objcopy/CopyConfig.h
@@ -72,6 +72,7 @@ struct CopyConfig {
StringMap<StringRef> SymbolsToRename;
// Boolean options
+ bool DeterministicArchives = true;
bool DiscardAll = false;
bool ExtractDWO = false;
bool KeepFileSymbols = false;
diff --git a/llvm/tools/llvm-objcopy/ObjcopyOpts.td b/llvm/tools/llvm-objcopy/ObjcopyOpts.td
index 8ed6df9a9f6..3b8453beecb 100644
--- a/llvm/tools/llvm-objcopy/ObjcopyOpts.td
+++ b/llvm/tools/llvm-objcopy/ObjcopyOpts.td
@@ -35,6 +35,22 @@ defm split_dwo
"<dwo-file>, then strip-dwo on the input file">,
MetaVarName<"dwo-file">;
+def enable_deterministic_archives
+ : Flag<["-", "--"], "enable-deterministic-archives">,
+ HelpText<"Enable deterministic mode when copying archives (use zero for "
+ "UIDs, GIDs, and timestamps).">;
+def D : Flag<["-"], "D">,
+ Alias<enable_deterministic_archives>,
+ HelpText<"Alias for --enable-deterministic-archives">;
+
+def disable_deterministic_archives
+ : Flag<["-", "--"], "disable-deterministic-archives">,
+ HelpText<"Disable deterministic mode when copying archives (use real "
+ "values for UIDs, GIDs, and timestamps).">;
+def U : Flag<["-"], "U">,
+ Alias<disable_deterministic_archives>,
+ HelpText<"Alias for --disable-deterministic-archives">;
+
def preserve_dates : Flag<[ "-", "--" ], "preserve-dates">,
HelpText<"Preserve access and modification timestamps">;
diff --git a/llvm/tools/llvm-objcopy/StripOpts.td b/llvm/tools/llvm-objcopy/StripOpts.td
index b224b1296b3..3657bdb703d 100644
--- a/llvm/tools/llvm-objcopy/StripOpts.td
+++ b/llvm/tools/llvm-objcopy/StripOpts.td
@@ -8,6 +8,22 @@ multiclass Eq<string name, string help> {
def help : Flag<["-", "--"], "help">;
+def enable_deterministic_archives
+ : Flag<["-", "--"], "enable-deterministic-archives">,
+ HelpText<"Enable deterministic mode when stripping archives (use zero "
+ "for UIDs, GIDs, and timestamps).">;
+def D : Flag<["-"], "D">,
+ Alias<enable_deterministic_archives>,
+ HelpText<"Alias for --enable-deterministic-archives">;
+
+def disable_deterministic_archives
+ : Flag<["-", "--"], "disable-deterministic-archives">,
+ HelpText<"Disable deterministic mode when stripping archives (use real "
+ "values for UIDs, GIDs, and timestamps).">;
+def U : Flag<["-"], "U">,
+ Alias<disable_deterministic_archives>,
+ HelpText<"Alias for --disable-deterministic-archives">;
+
defm output : Eq<"o", "Write output to <file>">,
MetaVarName<"output">;
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
index deaea5eff85..a033aaecb98 100644
--- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -147,7 +147,7 @@ static void executeObjcopyOnArchive(const CopyConfig &Config,
executeObjcopyOnBinary(Config, *Bin, MB);
Expected<NewArchiveMember> Member =
- NewArchiveMember::getOldMember(Child, true);
+ NewArchiveMember::getOldMember(Child, Config.DeterministicArchives);
if (!Member)
reportError(Ar.getFileName(), Member.takeError());
Member->Buf = MB.releaseMemoryBuffer();
@@ -157,9 +157,9 @@ static void executeObjcopyOnArchive(const CopyConfig &Config,
if (Err)
reportError(Config.InputFilename, std::move(Err));
- if (Error E =
- deepWriteArchive(Config.OutputFilename, NewArchiveMembers,
- Ar.hasSymbolTable(), Ar.kind(), true, Ar.isThin()))
+ if (Error E = deepWriteArchive(Config.OutputFilename, NewArchiveMembers,
+ Ar.hasSymbolTable(), Ar.kind(),
+ Config.DeterministicArchives, Ar.isThin()))
reportError(Config.OutputFilename, std::move(E));
}
OpenPOWER on IntegriCloud