[all-commits] [llvm/llvm-project] 681d5e: [llvm-readobj] Fix "Section" output when emitting ...

Paul Kirth via All-commits all-commits at lists.llvm.org
Fri Mar 17 18:36:06 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 681d5eecf7b32748763e5a8f56f7c334d8d6901e
      https://github.com/llvm/llvm-project/commit/681d5eecf7b32748763e5a8f56f7c334d8d6901e
  Author: Paul Kirth <paulkirth at google.com>
  Date:   2023-03-18 (Sat, 18 Mar 2023)

  Changed paths:
    M llvm/test/tools/llvm-readobj/ELF/relocations.test
    M llvm/tools/llvm-readobj/ELFDumper.cpp

  Log Message:
  -----------
  [llvm-readobj] Fix "Section" output when emitting relocations in JSON

Prior to this patch, the JSON output would emit an invalid key from the
shared LLVM implementation. This caused llvm-readobj to output invalid
JSON. This patch introduces a small helper function to print the
relocation information differently between the LLVM and JSON formats.

Before this patch:

```
    "Relocations": [Section (2) .rel.text {

      {
        "Relocation": {
          "Offset": 0,
          "Type": {
            "Value": "R_X86_64_NONE",
            "RawValue": 0
          },
          "Symbol": {
            "Value": "rel_0",
            "RawValue": 1
          }
        }
      },
      ...

```

After this patch:

```
   "Relocations": [
      {
        "SectionIdx": 2,
        "Relocs": [
          {
            "Relocation": {
              "Offset": 0,
              "Type": {
                "Name": "R_X86_64_NONE",
                "Value": 0
              },
              "Symbol": {
                "Name": "rel_0",
                "Value": 1
              }
            }
          },
          ...
```

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D137094




More information about the All-commits mailing list