Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for .gnu.attributes sections #509

Merged
merged 2 commits into from
Feb 17, 2023
Merged

Conversation

amshafer
Copy link
Contributor

@amshafer amshafer commented Feb 8, 2023

This adds partial support for SHT_GNU_ATTRIBUTES sections, which is of primary importance on powerpc systems since the endianness is specified as a file tag. For example see the Tag_GNU_Power_ABI_FP tag.

The details on the section format can be found here in section 4.3.6: https://static1.squarespace.com/static/59c4375b8a02c798d1cce06f/t/59d55a5a32601e2413a23988/1507154526861/ELF+for+ARM.pdf

This series only handles file tags, since they are the most straightforward. The symbol and section tag format requires being able to interact with ULEB128-encoded values, which I did not find an easy way to do without bringing in lots of third party dependencies. The file tags are the most common however, and paired with #508 allows for copying ppc64 shared libraries.

Copy link
Contributor

@philipc philipc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

ULEB128 support is fairly simple. We could add it to Bytes instead of needing to add dependencies. That can be left for a later PR though.

crates/examples/src/bin/elfcopy.rs Outdated Show resolved Hide resolved
crates/examples/src/bin/elfcopy.rs Outdated Show resolved Hide resolved
crates/examples/src/bin/elfcopy.rs Outdated Show resolved Hide resolved
src/read/elf/section.rs Outdated Show resolved Hide resolved
src/read/elf/section.rs Outdated Show resolved Hide resolved
src/read/elf/version.rs Outdated Show resolved Hide resolved
src/read/elf/version.rs Outdated Show resolved Hide resolved
src/read/elf/version.rs Outdated Show resolved Hide resolved
src/read/elf/version.rs Outdated Show resolved Hide resolved
src/write/elf/writer.rs Outdated Show resolved Hide resolved
src/read/elf/version.rs Outdated Show resolved Hide resolved
src/read/elf/version.rs Outdated Show resolved Hide resolved
src/read/elf/version.rs Outdated Show resolved Hide resolved
src/read/elf/version.rs Outdated Show resolved Hide resolved
src/read/elf/version.rs Outdated Show resolved Hide resolved
src/read/elf/version.rs Outdated Show resolved Hide resolved
src/read/elf/version.rs Outdated Show resolved Hide resolved
src/write/elf/writer.rs Outdated Show resolved Hide resolved
@philipc philipc merged commit 4f40e07 into gimli-rs:master Feb 17, 2023
@philipc
Copy link
Contributor

philipc commented Feb 21, 2023

Do you know how to create a file with a .gnu.attributes section? I tried compiling with powerpc-linux-gnu-gcc and powerpc64-linux-gnu-gcc but it doesn't produce this section.

@amshafer
Copy link
Contributor Author

I was seeing it with little endian, so maybe powerpc64le-linux-gnu-gcc is the target you need?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants