[PATCH] D146431: [AIX][Driver] Implement -mxcoff-build-id option.
wael yehia via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 27 08:37:51 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGda92f2fb33c4: [AIX][Driver] Implement -mxcoff-build-id option (authored by w2yehia).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146431/new/
https://reviews.llvm.org/D146431
Files:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/xcoff-build-id.c
Index: clang/test/Driver/xcoff-build-id.c
===================================================================
--- /dev/null
+++ clang/test/Driver/xcoff-build-id.c
@@ -0,0 +1,14 @@
+// RUN: touch %t.o
+// RUN: %clang --target=powerpc64-ibm-aix -### %t.o -mxcoff-build-id=0x12 2>&1 | FileCheck %s
+// Test that:
+// 1) our ldrinfo flag comes before any user specified ldrinfo flag;
+// 2) upper case hex digits are converted to lower case;
+// 3) a zero is added when odd number of digits is specified in the HEXSTRING.
+// RUN: %clang --target=powerpc-ibm-aix -### %t.o -Wl,-bdbg:ldrinfo:FOO -mxcoff-build-id=0x011ffFF 2>&1 | FileCheck %s --check-prefix=OTHER
+
+// RUN: %clang --target=powerpc-ibm-aix -### %t.o -mxcoff-build-id=ff 2>&1 | FileCheck %s --check-prefix=BAD_INPUT
+// RUN: %clang --target=powerpc-ibm-aix -### %t.o -mxcoff-build-id=0x0z 2>&1 | FileCheck %s --check-prefix=BAD_INPUT
+
+CHECK: "-bdbg:ldrinfo:xcoff_binary_id:0x12"
+OTHER: "-bdbg:ldrinfo:xcoff_binary_id:0x0011ffff" {{.*}} "-bdbg:ldrinfo:FOO"
+BAD_INPUT: clang: error: unsupported argument {{.*}} to option '-mxcoff-build-id='
Index: clang/lib/Driver/ToolChains/AIX.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -143,6 +143,22 @@
Args.hasArg(options::OPT_coverage))
CmdArgs.push_back("-bdbg:namedsects:ss");
+ if (Arg *A =
+ Args.getLastArg(clang::driver::options::OPT_mxcoff_build_id_EQ)) {
+ StringRef BuildId = A->getValue();
+ if (BuildId[0] != '0' || BuildId[1] != 'x' ||
+ BuildId.find_if_not(llvm::isHexDigit, 2) != StringRef::npos)
+ ToolChain.getDriver().Diag(diag::err_drv_unsupported_option_argument)
+ << A->getSpelling() << BuildId;
+ else {
+ std::string LinkerFlag = "-bdbg:ldrinfo:xcoff_binary_id:0x";
+ if (BuildId.size() % 2) // Prepend a 0 if odd number of digits.
+ LinkerFlag += "0";
+ LinkerFlag += BuildId.drop_front(2).lower();
+ CmdArgs.push_back(Args.MakeArgString(LinkerFlag));
+ }
+ }
+
// Specify linker output file.
assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
if (Output.isFilename()) {
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3905,6 +3905,8 @@
def mzvector : Flag<["-"], "mzvector">, Alias<fzvector>;
def mno_zvector : Flag<["-"], "mno-zvector">, Alias<fno_zvector>;
+def mxcoff_build_id_EQ : Joined<["-"], "mxcoff-build-id=">, Group<Link_Group>, MetaVarName<"<0xHEXSTRING>">,
+ HelpText<"On AIX, request creation of a build-id string, \"0xHEXSTRING\", in the string table of the loader section inside the linked binary">;
def mignore_xcoff_visibility : Flag<["-"], "mignore-xcoff-visibility">, Group<m_Group>,
HelpText<"Not emit the visibility attribute for asm in AIX OS or give all symbols 'unspecified' visibility in XCOFF object file">,
Flags<[CC1Option]>;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146431.508676.patch
Type: text/x-patch
Size: 3079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230327/296d795b/attachment.bin>
More information about the cfe-commits
mailing list