[lld] [lld] Add support for EC code map. (PR #69101)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 04:22:12 PST 2023


================
@@ -528,6 +531,53 @@ bool Writer::createThunks(OutputSection *os, int margin) {
   return addressesChanged;
 }
 
+// Create a code map for CHPE metadata.
+void Writer::createECCodeMap() {
+  if (!isArm64EC(ctx.config.machine))
+    return;
+
+  // Clear the map in case we were're recomputing the map after adding
+  // a range extension thunk.
+  codeMap.clear();
+
+  std::optional<chpe_range_type> lastType;
+  Chunk *first, *last;
+
+  auto closeRange = [&]() {
+    if (lastType) {
+      codeMap.push_back({first, last, *lastType});
+      lastType.reset();
+    }
+  };
+
+  for (OutputSection *sec : ctx.outputSections) {
+    if (!sec->isCodeSection()) {
+      closeRange();
+      continue;
+    }
+
+    for (Chunk *c : sec->chunks) {
+      // Skip empty section chunks. MSVC does not seem to do that and
----------------
mstorsjo wrote:

Nit: I'd qualify this to "MS link.exe" instead of "MSVC" here perhaps.

https://github.com/llvm/llvm-project/pull/69101


More information about the llvm-commits mailing list