1502 Commits

Author SHA1 Message Date
Csanád Hajdú
a190f15d2b
[AArch64] Add support for SHF_AARCH64_PURECODE ELF section flag (1/3) (#125687)
Add support for the new SHF_AARCH64_PURECODE ELF section flag:
https://github.com/ARM-software/abi-aa/pull/304

The general implementation follows the existing one for ARM targets.
Generating object files with the `SHF_AARCH64_PURECODE` flag set is
enabled by the `+execute-only` target feature.

Related PRs:
* Clang: https://github.com/llvm/llvm-project/pull/125688
* LLD: https://github.com/llvm/llvm-project/pull/125689
2025-02-14 08:56:07 +00:00
Aiden Grossman
808b1c11a2
[ELF] Add support for CREL to getSectionAndRelocations
This patch updates the getSectionAndRelocations function to also support
CREL relocation sections. Unit tests have been added. This patch also
updates consumers to say they explicitly do not support CREL format
relocations. Subsequent patches will make the consumers work with CREL
format relocations and also add in testing support.

Reviewers: red1bluelost, MaskRay, rlavaee

Reviewed By: MaskRay

Pull Request: https://github.com/llvm/llvm-project/pull/126445
2025-02-10 10:57:19 -08:00
zhijian lin
ec60e1d8e2
[XCOFF][llvm-readobj] Print symbol value kind when dumping symbols (#125861)
llvm-readobj print out symbol value name for xcoff symbol table.

reference doc:
https://www.ibm.com/docs/en/aix/7.2?topic=formats-xcoff-object-file-format#XCOFF__yaa3i18fjbau
2025-02-10 09:37:04 -05:00
Ming-Yi Lai
a1984ec5ea
[llvm-readobj][ELF][RISCV] Dump .note.gnu.property section contents (#125642)
RISCV Zicfilp/Zicfiss extensions uses the `.note.gnu.property` section
to store flags indicating the adoption of features based on these
extensions. This patch enables the llvm-readobj/llvm-readelf tools to
dump these flags with the `--note` flag.
2025-02-07 13:55:16 +08:00
Daniel Paoliello
2201164477
[llvm] Win x64 Unwind V2 2/n: Support dumping UOP_Epilog (#110338)
Adds support to objdump and readobj for reading the `UOP_Epilog` entries
of Windows x64 unwind v2.

`UOP_Epilog` has a weird format:

The first `UOP_Epilog` in the unwind data is the "header":
* The least-significant bit of `OpInfo` is the "At End" flag, which
signifies that there is an epilog at the very end of the associated
function.
* `CodeOffset` is the length each epilog described by the current unwind
information (all epilogs have the same length).

Any subsequent `UOP_Epilog` represents another epilog for the current
function, where `OpInfo` and `CodeOffset` are combined to a 12-bit value
which is the offset of the beginning of the epilog from the end of the
current function. If the offset is 0, then this entry is actually
padding and can be ignored.
2025-01-13 16:53:42 -08:00
Chandler Carruth
dd647e3e60
Rework the Option library to reduce dynamic relocations (#119198)
Apologies for the large change, I looked for ways to break this up and
all of the ones I saw added real complexity. This change focuses on the
option's prefixed names and the array of prefixes. These are present in
every option and the dominant source of dynamic relocations for PIE or
PIC users of LLVM and Clang tooling. In some cases, 100s or 1000s of
them for the Clang driver which has a huge number of options.

This PR addresses this by building a string table and a prefixes table
that can be referenced with indices rather than pointers that require
dynamic relocations. This removes almost 7k dynmaic relocations from the
`clang` binary, roughly 8% of the remaining dynmaic relocations outside
of vtables. For busy-boxing use cases where many different option tables
are linked into the same binary, the savings add up a bit more.

The string table is a straightforward mechanism, but the prefixes
required some subtlety. They are encoded in a Pascal-string fashion with
a size followed by a sequence of offsets. This works relatively well for
the small realistic prefixes arrays in use.

Lots of code has to change in order to land this though: both all the
option library code has to be updated to use the string table and
prefixes table, and all the users of the options library have to be
updated to correctly instantiate the objects.

Some follow-up patches in the works to provide an abstraction for this
style of code, and to start using the same technique for some of the
other strings here now that the infrastructure is in place.
2024-12-11 15:44:44 -08:00
David Spickett
088e74cf73
[llvm][llvm-readobj] Add NT_ARM_GCS Linux core note type (#117545)
The ARM Guarded Control Stack extension (GCS) is similar to existing
shadow stack extensions for other architectures.

The core note will include which features of GCS are enabled, which have
been locked in their current state, and the stack pointer of the shadow
stack.

Note that 0x40f is NT_ARM_POE, FPMR is supported by LLDB and GCS will be
soon, POE is not at this time. So NT_ARM_POE will be added when that
work starts.

See
https://github.com/torvalds/linux/blob/master/include/uapi/linux/elf.h.
2024-12-11 11:19:48 +00:00
Amy Kwan
f31099ce58
[PowerPC][AIX] Emit PowerPC version for XCOFF (#113214)
This PR emits implements the ability to emit the PPC version for both
assembly and object files on AIX.
2024-12-10 11:11:50 -05:00
Matt Arsenault
a6fc489bb7
AMDGPU: Add gfx950 subtarget definitions (#116307)
Mostly a stub, but adds some baseline tests and
tests for removed instructions.
2024-11-18 10:41:14 -08:00
Shilei Tian
de0fd64bed
[AMDGPU] Introduce a new generic target gfx9-4-generic (#115190)
This patch introduces a new generic target, `gfx9-4-generic`. Since it doesn’t support FP8 and XF32-related instructions, the patch includes several code reorganizations to accommodate these changes.
2024-11-12 23:11:05 -05:00
Kazu Hirata
3297858c19
[llvm-readobj] Use heterogenous lookups with std::map (NFC) (#114929)
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.
2024-11-05 09:38:11 -08:00
Carl Ritson
076aac59ac
[AMDGPU] Add a new target for gfx1153 (#113138) 2024-10-23 12:56:58 +09:00
Jacek Caban
5a68ac8ba7
[llvm-readobj][COFF] Add support for version 2 of CHPE metadata (#109545) 2024-09-22 22:36:39 +02:00
JOE1994
eb11f576a4 [llvm][tools] Strip unneeded uses of raw_string_ostream::str() (NFC)
Remove excess layer of indirection.
2024-09-13 07:12:15 -04:00
JOE1994
6c0b1e75e3 [llvm][tools] Strip unneeded uses of raw_string_ostream::str() (NFC)
Remove unnecessary layer of indirection.
2024-09-13 06:23:54 -04:00
Daniil Kovalev
de5deb7b07
[PAC][ELF][AArch64] Encode several ptrauth features in PAuth core info (#102508)
For llvm_linux platform, define the following meaning for bits 9, 10,
11:

- bit 9: set if indirect gotos signing is enabled;
- bit 10: set if type info vtable pointer discrimination is enabled;
- bit 11: set if function pointer type discrimination is enabled.
2024-08-19 12:53:43 +03:00
Koakuma
e61776a0ed
[SPARC][Utilities] Add names for SPARC ELF flags in LLVM binary utilities (#102843)
This allows us to use and print readable names in LLVM binary utilities.
2024-08-15 23:49:01 +07:00
David Spickett
a07c6d9e34
[llvm][llvm-readobj] Add NT_ARM_FPMR corefile note type (#102594)
This contains the fpmr register which was added in Armv9.5-a. This
register mainly contains controls for fp8 formats.

It was added to the Linux Kernel in

4035c22ef7.
2024-08-12 09:22:06 +01:00
Jacek Caban
1d77dd50f1
[llvm-readobj][COFF] Dump hybrid objects for ARM64X files. (#102245) 2024-08-09 15:55:28 +02:00
Jacek Caban
94d5398400
[Object][COFF][llvm-readobj] Add support for ARM64X dynamic relocations. (#97229) 2024-08-06 22:06:08 +02:00
Jacek Caban
f949b03661
[llvm-readobj][NFC] Don't use startLine in a middle of a line in ObjDumper. (#102071) 2024-08-06 18:04:23 +02:00
Daniil Kovalev
15d4a84e79
[PAC][ELF][AArch64] Encode signed GOT flag in PAuth core info (#96159)
Treat 8th bit of version value for llvm_linux platform as signed GOT
flag.

- clang: define `PointerAuthELFGOT` LangOption and set 8th bit of
  `aarch64-elf-pauthabi-version` LLVM module flag correspondingly;

- llvm-readobj: print `PointerAuthELFGOT` or `!PointerAuthELFGOT` in
  version description of llvm_linux platform depending on whether the flag
  is set.
2024-08-06 18:24:01 +03:00
Daniil Kovalev
6e45fa95be
[PAC][AArch64] Support init/fini array signing (#96478)
If both `-fptrauth-init-fini` and `-fptrauth-calls` are passed, sign
function pointers in `llvm.global_ctors` and `llvm.global_dtors` with
constant discriminator 0xD9D4
(`ptrauth_string_discriminator("init_fini")`). Additionally, if
`-fptrauth-init-fini-address-discrimination` is passed, address
discrimination is used for signing (otherwise, just constant
discriminator is used).

For address discrimination, we use it's special form since uses of
`llvm.global_{c|d}tors` are disallowed (see
`Verifier::visitGlobalVariable`) and we can't emit `getelementptr`
expressions referencing these special arrays. A signed ctor/dtor pointer
with special address discrimination applied looks like the following:

```
ptr ptrauth (ptr @foo, i32 0, i64 55764, ptr inttoptr (i64 1 to ptr))
```
2024-08-06 08:02:13 +03:00
Kazu Hirata
75bc20ff89
[llvm] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#97914) 2024-07-07 08:23:41 +09:00
Fred Grim
ab930ee7ca
[llvm-readobj][ELF] Alter JSON/LLVM output on note sections to allow for multiple notes per section in JSON (#96813)
It turns out that the notes section for corefiles (or really any elf
file with multiple notes) is set up in such a way for LLVM formatted
output that the JSON equivalent only has the last note since the notes
are held in a dictionary with every key being Note. This pr alters the
layout for the notes to a list of dictionaries to sidestep this issue
for JSON output. Prior to this pr a note section in the output looked
like (for LLVM output):

```
Notes [
  NoteSection {
    Name: <?>
    Offset: 0x2148
    Size: 0x1F864
    Note {
      Owner: CORE
      Data size: 0x150
      Type: NT_PRSTATUS (prstatus structure)
      Description data (
        0000: 06000000 00000000 00000000 06000000  |................|
        ...
      )
    }
    Note {
      Owner: CORE
      Data size: 0x88
      Type: NT_PRPSINFO (prpsinfo structure)
      Description data (
        0000: 02440000 00000000 04054040 00000000  |.D........@@....|
	....
```

But is now:

```
NoteSections [
  NoteSection {
    Name: <?>
    Offset: 0x2148
    Size: 0x1F864
    Notes [
      {
        Owner: CORE
        Data size: 0x150
        Type: NT_PRSTATUS (prstatus structure)
        Description data (
          0000: 06000000 00000000 00000000 06000000  |................|
          ...
        )
      }
      {
        Owner: CORE
        Data size: 0x88
        Type: NT_PRPSINFO (prpsinfo structure)
        Description data (
          0000: 02440000 00000000 04054040 00000000  |.D........@@....|
	  ...
```
2024-07-03 09:19:18 -07:00
serge-sans-paille
488fdb7d12
Revert "[llvm-readobj][ELF] Test multivalued rpath entries and alter the output for readobj to emphasize the single valued nature of NEEDED, SONAME, USED etc. (#96562)"
Reverted due to output change that breaks downstream project, see

https://github.com/llvm/llvm-project/pull/96562#issuecomment-2204938038

This reverts commit 161e1689ba98fabba71cac21f536708c78e9d7b0.
2024-07-03 14:24:08 +02:00
Fangrui Song
1b704e889f
[MC,llvm-readobj,yaml2obj] Support CREL relocation format
CREL is a compact relocation format for the ELF object file format.

This patch adds integrated assembler support (using the RELA form)
available with `llvm-mc -filetype=obj -crel a.s -o a.o`.
A dependent patch will add `clang -c -Wa,--crel,--allow-experimental-crel`.

Also add llvm-readobj support (for both REL and RELA forms) to
facilitate testing the assembler. Additionally, yaml2obj gains support
for the RELA form to aid testing with llvm-readobj.

We temporarily assign the section type code 0x40000020 from the generic
range to `SHT_CREL`. We avoided using `SHT_LLVM_` or `SHT_GNU_` to
avoid code churn and maintain broader applicability for interested psABIs.
Similarly, `DT_CREL` is temporarily 0x40000026.

LLVM will change the code and break compatibility. This is not an issue
if all relocatable files using CREL are regenerated (aka no prebuilt
relocatable files).

Link: https://discourse.llvm.org/t/rfc-crel-a-compact-relocation-format-for-elf/77600

Pull Request: https://github.com/llvm/llvm-project/pull/91280
2024-07-01 10:32:02 -07:00
Fred Grim
161e1689ba
[llvm-readobj][ELF] Test multivalued rpath entries and alter the output for readobj to emphasize the single valued nature of NEEDED, SONAME, USED etc. (#96562)
In the context of #95976 it became clear that the output for readobj
implied multi valued entries in several cases in the elf headers that
the documentation only allowed for a single value. DT_NEEDED is the
example here where the value is an offset into the string table without
any sort of separator that could give you multiple entries. This patch
alters the LLVM output so that the single valued nature is emphasized.
For example the output was:
```
DynamicSection [ (35 entries)
  Tag                Type         Name/Value
  0x000000000000001D RUNPATH      Library runpath: [$ORIGIN/../lib:]
  0x0000000000000001 NEEDED       Shared library: [libm.so.6]
  0x0000000000000001 NEEDED       Shared library: [libz.so.1]
  0x0000000000000001 NEEDED       Shared library: [libzstd.so.1]
```
and is now
```
  Tag                Type         Name/Value
  0x000000000000001D RUNPATH      Library runpath: [$ORIGIN/../lib:]
  0x0000000000000001 NEEDED       Shared library: libm.so.6
  0x0000000000000001 NEEDED       Shared library: libz.so.1
  0x0000000000000001 NEEDED       Shared library: libzstd.so.1
```
This pr also tests that multi-valued rpaths are handled correctly in the
JSON case (i.e. they become proper lists) like:
```
{
    "Tag": 15,
    "Type": "RPATH",
    "Value": 9,
    "Path": [
        "x",
        "w",
        "U"
    ]
},
```
when separated by :
2024-06-26 06:41:53 -07:00
Fred Grim
0ab81986be
[llvm-readobj][ELF] Implement JSON output for --dynamic-table (#95976)
When printing JSON output with --dynamic-table I noticed that the output
is invalid JSON. This patch overrides the printDynamicTable() function
in the JSONELFDumper to return a list of dictionaries for the
DynamicSection value.
Before the output was:
```
 {
    "FileSummary": {
      "File": "bin/llvm-readelf",
      "Format": "elf64-x86-64",
      "Arch": "x86_64",
      "AddressSize": "64bit",
      "LoadName": "<Not found>"
    }DynamicSection [ (35 entries)
  Tag                Type         Name/Value
  0x000000000000001D RUNPATH      Library runpath: [$ORIGIN/../lib:]
  0x0000000000000001 NEEDED       Shared library: [libm.so.6]
  0x0000000000000001 NEEDED       Shared library: [libz.so.1]
  0x0000000000000001 NEEDED       Shared library: [libzstd.so.1]
```
Now the output looks like:
```
 "DynamicSection": [
      {
        "Tag": 29,
        "Type": "RUNPATH",
        "Value": 6322,
        "Path": [
          "$ORIGIN/../lib"
        ]
      },
      {
        "Tag": 1,
        "Type": "NEEDED",
        "Value": 6109,
        "Library": "libm.so.6"
      },
```
2024-06-24 11:25:18 -07:00
Shilei Tian
1ca0055f45
[AMDGPU] Add a new target gfx1152 (#94534) 2024-06-06 12:16:11 -04:00
Miguel A. Arroyo
0cb66a7bd5
[llvm-readobj][COFF] Consistent PDBGUID Formatting (#94256)
## Consistent PDB GUID in `llvm-readobj`

Currently, the PDB GUID is shown as a byte array:
`PDBGUID: (D8 4C 88 D9 26 15 1F 11 4C 4C 44 20 50 44 42 2E)`

This is inconsistent with `llvm-pdbutil` (e.g. `llvm-pdbutil dump
--summary`) which shows it as a hexadecimal string.
Additionally, `yaml2obj` uses the same hexadecimal string format.

In general, the hexadecimal string is the common representation for PDB
GUIDs on Windows.

This PR changes it to be consistent as shown below:
`PDBGUID: {D9884CD8-1526-111F-4C4C-44205044422E}`
2024-06-04 09:43:24 -07:00
Konstantin Zhuravlyov
775f1cd34d
AMDGPU: Add gfx12-generic target (#93875) 2024-05-31 12:46:44 -04:00
Fred Grim
942a6af6ad
[llvm-readobj] Fixes malformed json on JSON printed corefiles (#92835)
This patch fixes an issue where, when printing corefile notes with
llvm-readobj as json, the dumper generated llvm formatted output which
isn't valid json. This alters the dumper to, in the NT_FILE, note, dump
properly formatted json data.

Prior to this patch the JSON output was formatted like:
 ```
                "Mapping": [
                  "Start": 4096,
                  "End": 8192,
                  "Offset": 12288,
                  "Filename": "/path/to/a.out"
                ],
 ```
 Whereas now it is formatted as:
  ```
                "Mappings": [
                  {
                    "Start": 4096,
                    "End": 8192,
                    "Offset": 12288,
                    "Filename": "/path/to/a.out"
                  },
  ```
Which is valid. Additionally the LLVM output has changed to match the
structure of the JSON output (i.e. instead of lists of keys it is a list
of dictionaries)
2024-05-23 08:55:17 -07:00
Fangrui Song
89c95effe8
[llvm-readobj] Remove --raw-relr
https://reviews.llvm.org/D47919 dumped RELR relocations as
`R_*_RELATIVE` and added --raw-relr (not in GNU) for testing purposes
(more readable than `llvm-readelf -x .relr.dyn`). The option is obsolete
after `llvm-readelf -r` output gets improved (#89162).

Since --raw-relr never seems to get more adoption. Let's remove it to
avoid some complexity.

Pull Request: https://github.com/llvm/llvm-project/pull/89426
2024-04-22 12:35:04 -07:00
Fangrui Song
d86079f93c
[llvm-readelf] Print more information for RELR
llvm-readelf/llvm-readobj print RELR as REL relocations with a fixed
type (e.g. `R_*_RELATIVE`). GNU readelf printed only addresses and have
recently switched to a more descritive style that includes a symbolic
address column (symbolized using .symtab/.strtab) (milestone: binutils
2.43).

This patch implements the new GNU style, which seems superior to the
current REL style and essentially obsoletes LLVM-specific --raw-relr
(`printRelrReloc`).

Pull Request: https://github.com/llvm/llvm-project/pull/89162
2024-04-19 09:21:57 -07:00
Ramkumar Ramachandra
06714e1bfe
llvm-readobj/ARM: activate big-endian attribute printing (#87806)
Activate attribute printing for big-endian encoding for ARM. The
supporting code already exists, and the patch is trivial.

Fixes #62400.
2024-04-15 09:36:40 +01:00
Simon Pilgrim
1c7fda9f4c Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFC. 2024-04-04 12:26:34 +01:00
Daniil Kovalev
4f19f15a60
[PAC][llvm-readobj][AArch64][ELF] Support GNU_PROPERTY_AARCH64_FEATURE_PAUTH (#87545)
Reland #85231 after fixing build failure
https://lab.llvm.org/buildbot/#/builders/186/builds/15631.
Use `PRIx64` for format output of `uint64_t` as hex.
Original PR description below.

This adds support for `GNU_PROPERTY_AARCH64_FEATURE_PAUTH` feature (as
defined in https://github.com/ARM-software/abi-aa/pull/240) handling in
llvm-readobj and llvm-readelf. The following constants for supported
platforms are also introduced:

- `AARCH64_PAUTH_PLATFORM_INVALID = 0x0`
- `AARCH64_PAUTH_PLATFORM_BAREMETAL = 0x1`
- `AARCH64_PAUTH_PLATFORM_LLVM_LINUX = 0x10000002`

For the llvm_linux platform, output of the tools contains descriptions
of PAuth features which are enabled/disabled depending on the version
value. Version value bits correspond to the following `LangOptions`
defined in #85232:

- bit 0: `PointerAuthIntrinsics`;
- bit 1: `PointerAuthCalls`;
- bit 2: `PointerAuthReturns`;
- bit 3: `PointerAuthAuthTraps`;
- bit 4: `PointerAuthVTPtrAddressDiscrimination`;
- bit 5: `PointerAuthVTPtrTypeDiscrimination`;
- bit 6: `PointerAuthInitFini`.

Support for `.note.AARCH64-PAUTH-ABI-tag` is dropped since it's deleted
from the spec in ARM-software/abi-aa#250.
2024-04-04 08:20:13 +03:00
Daniil Kovalev
c45861f437
Revert "[PAC][llvm-readobj][AArch64][ELF] Support GNU_PROPERTY_AARCH64_FEATURE_PAUTH" (#87434)
Reverts llvm/llvm-project#85231

See build failure
https://lab.llvm.org/buildbot/#/builders/186/builds/15631
2024-04-03 03:15:47 +03:00
Daniil Kovalev
5029949952
[PAC][llvm-readobj][AArch64][ELF] Support GNU_PROPERTY_AARCH64_FEATURE_PAUTH (#85231)
This adds support for `GNU_PROPERTY_AARCH64_FEATURE_PAUTH` feature (as
defined in https://github.com/ARM-software/abi-aa/pull/240) handling in
llvm-readobj and llvm-readelf. The following constants for supported
platforms are also introduced:

- `AARCH64_PAUTH_PLATFORM_INVALID = 0x0`
- `AARCH64_PAUTH_PLATFORM_BAREMETAL = 0x1`
- `AARCH64_PAUTH_PLATFORM_LLVM_LINUX = 0x10000002`

For the llvm_linux platform, output of the tools contains descriptions
of PAuth features which are enabled/disabled depending on the version
value. Version value bits correspond to the following `LangOptions`
defined in #85232:

- bit 0: `PointerAuthIntrinsics`;
- bit 1: `PointerAuthCalls`;
- bit 2: `PointerAuthReturns`;
- bit 3: `PointerAuthAuthTraps`;
- bit 4: `PointerAuthVTPtrAddressDiscrimination`;
- bit 5: `PointerAuthVTPtrTypeDiscrimination`;
- bit 6: `PointerAuthInitFini`.

Support for `.note.AARCH64-PAUTH-ABI-tag` is dropped since it's deleted
from the spec in ARM-software/abi-aa#250.
2024-04-03 00:28:47 +03:00
Fangrui Song
2763353891
[Object,ELFType] Rename TargetEndianness to Endianness (#86604)
`TargetEndianness` is long and unwieldy. "Target" in the name is confusing. Rename it to "Endianness".

I cannot find noticeable out-of-tree users of `TargetEndianness`, but
keep `TargetEndianness` to make this patch safer. `TargetEndianness`
will be removed by a subsequent change.
2024-03-28 09:10:34 -07:00
quic-areg
31f4b329c8
[Hexagon] ELF attributes for Hexagon (#85359)
Defines a subset of attributes and emits them to a section called
.hexagon.attributes.

The current attributes recorded are the attributes needed by
llvm-objdump to automatically determine target features and eliminate
the need to manually pass features.
2024-03-19 16:22:30 -05:00
Fangrui Song
24f22b3f93
[llvm-readelf] Print a blank line for the first hex/string dump
GNU readelf prints a blank line before the first hex/string dump, which
serves as a separator when there are other dump operations. Port the
behavior.

Pull Request: https://github.com/llvm/llvm-project/pull/85744
2024-03-19 09:38:55 -07:00
Igor Kudrin
fe84764724
[DWARF] Dump an updated location for DW_CFA_advance_loc* (#84274)
When dumping FDEs, `readelf` prints new location values after
`DW_CFA_advance_loc(*)` instructions, which looks quite convenient:

```
> readelf -wf test.o
...
... FDE ... pc=0000000000000030..0000000000000064
  DW_CFA_advance_loc: 4 to 0000000000000034
  ...
  DW_CFA_advance_loc: 4 to 0000000000000038
...
```

This patch makes `llvm-dwarfdump` and `llvm-readobj` do the same.
2024-03-08 07:34:36 +07:00
zhijian lin
3034632a27
[llvm-readobj] enable demangle option for the xcoff object file (#78455)
enable `--demangle` option for the xcoff object file for llvm-readobj
2024-03-01 09:21:11 -05:00
Micah Weston
9ca8db352d
[SHT_LLVM_BB_ADDR_MAP] Adds pretty printing of BFI and BPI for PGO Analysis Map in tools. (#82292)
Primary change is to add a flag `--pretty-pgo-analysis-map` to
llvm-readobj and llvm-objdump that prints block frequencies and branch
probabilities in the same manner as BFI and BPI respectively. This can
be helpful if you are manually inspecting the outputs from the tools.

In order to print, I moved the `printBlockFreqImpl` function from
Analysis to Support and renamed it to `printRelativeBlockFreq`.
2024-02-27 14:13:00 -05:00
Fangrui Song
26d71d9ed5
[llvm-readobj,ELF] Support --decompress/-z (#82594)
When a section has the SHF_COMPRESSED flag, -p/-x dump the compressed
content by default. In GNU readelf, if --decompress/-z is specified,
-p/-x will dump the decompressed content. This patch implements the
option.

Close #82507
2024-02-22 09:24:21 -08:00
Fangrui Song
2167881f51 [ARM,MC] Support FDPIC relocations
Linux kernel fs/binfmt_elf_fdpic.c supports FDPIC for MMU-less systems.
GCC/binutils/qemu support FDPIC ABI for ARM
(https://github.com/mickael-guene/fdpic_doc).
_ARM FDPIC Toolchain and ABI_ provides a summary.

This patch implements FDPIC relocations to the integrated assembler.
There are 6 static relocations and 2 dynamic relocations, with
R_ARM_FUNCDESC as both static and dynamic.

gas requires `--fdpic` to assemble data relocations like `.word f(FUNCDESC)`.
This patch adds `MCTargetOptions::FDPIC` and reports an error if FDPIC
is not set.

Pull Request: https://github.com/llvm/llvm-project/pull/82187
2024-02-21 10:13:26 -08:00
stephenpeckham
26db845536
[XCOFF] Support the subtype flag in DWARF section headers (#81667)
The section headers for XCOFF files have a subtype flag for Dwarf
sections. This PR updates obj2yaml, yaml2obj, and llvm-readobj so that
they recognize the subtype.
2024-02-20 08:42:12 -06:00
Frederic Cambus
a8d7511811
[llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82122)
Reference: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h
2024-02-20 09:12:58 +01:00