[all-commits] [llvm/llvm-project] 23fd6e: [llvm-readobj] Fix JSON output for Relocations

Paul Kirth via All-commits all-commits at lists.llvm.org
Fri Mar 17 16:58:15 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 23fd6e360c2cfe1263474c65c5cb605dfbf0dfeb
      https://github.com/llvm/llvm-project/commit/23fd6e360c2cfe1263474c65c5cb605dfbf0dfeb
  Author: Paul Kirth <paulkirth at google.com>
  Date:   2023-03-17 (Fri, 17 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 JSON output for Relocations

The existing JSON incorrectly outputs line breaks and other invalid JSON.

Example Before this patch:

```
...
"Relocations":[Section (9) .rela.dyn {
  0xA3B0 R_X86_64_RELATIVE - 0x43D0
  0xA3B8 R_X86_64_RELATIVE - 0x4A30
...
```

Example After this patch:

```
...
"Relocations":[Section (9) .rela.dyn {
{"Relocation":{"Offset":41904,"Type":{"Value":"R_X86_64_RELATIVE","RawValue":8},
"Symbol":{"Value":"","RawValue":0},"Addend":17360}},
{"Relocation":{"Offset":41912,"Type":{"Value":"R_X86_64_RELATIVE","RawValue":8},
"Symbol":{"Value":"","RawValue":0},"Addend":18992}},
{"Relocation":{"Offset":41920,"Type":{"Value":"R_X86_64_RELATIVE","RawValue":8},
"Symbol":{"Value":"","RawValue":0},"Addend":17440}},
...
```

Note there are still issues with the Section, but each Relocation is
now a valid JSON object that can be parsed. Future patches will address
the issues regarding JSON output for the Section.

Reviewed By: jhenderson

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




More information about the All-commits mailing list