[lld] [llvm] RFC: [llvm-readobj] Support FDO package metadata in readelf (PR #214375)

Dan McGregor via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 08:09:09 PDT 2026


================
@@ -8733,6 +8763,15 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printNotes() {
     if (Name == "GNU") {
       if (printGNUNoteLLVMStyle<ELFT>(Type, Descriptor, W, EMachine))
         return Error::success();
+    } else if (Name == "FDO") {
+      if (std::optional<FDONote> N = getFDONote<ELFT>(Type, Descriptor)) {
+        auto f = llvm::json::parse(N->Value);
+        if (f)
+          W.printObject(N->Type, f.get());
----------------
dankm wrote:

Yes, that's exactly the point. Here's my quickly contrived test case's output:
```
$ ./bin/llvm-readobj --elf-output-style=GNU -n a.out
Displaying notes found in: .note.package
  Owner                Data size        Description
  FDO                  0x00000030       FDO_PACKAGING_METADATA
    Packaging Metadata: {"zzomgwtfbbq":null, "foo": "bar", "num": 17.0}
```
Note the raw string's ordering of the JSON object. Compare it to the LLVM output:
```
$ ./bin/llvm-readobj --elf-output-style=LLVM -n a.out
File: a.out
Format: elf64-x86-64
Arch: x86_64
AddressSize: 64bit
LoadName: <Not found>
NoteSections [
  NoteSection {
    Name: .note.package
    Offset: 0x158
    Size: 0x40
    Notes [
      {
        Owner: FDO
        Data size: 0x30
        Type: FDO_PACKAGING_METADATA
        Packaging Metadata: {
          "foo": "bar",
          "num": 17,
          "zzomgwtfbbq": null
        }
      }
    ]
  }
]
```

If the JSON fails to parse it outputs a raw string. That could be for any reason it's not parsing, including invalid JSON or somebody simply using a raw string.

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


More information about the llvm-commits mailing list