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

linker: Create GNU_EH_FRAME header by default when producing ELFs #73564

Merged
merged 1 commit into from
Jul 2, 2020

Conversation

petrochenkov
Copy link
Contributor

Do it in a centralized way in link.rs instead of individual target specs.

The opt-out is -Clink-arg=(-Wl,)--no-eh-frame-hdr if necessary.

Fixes #73451
cc #73483

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 20, 2020
@petrochenkov
Copy link
Contributor Author

r? @cuviper @Amanieu

@rust-highfive rust-highfive assigned cuviper and unassigned eddyb Jun 20, 2020
@petrochenkov petrochenkov changed the title linker: Implicitly create GNU_EH_FRAME header when producing ELFs linker: Create GNU_EH_FRAME header by default when producing ELFs Jun 20, 2020
@petrochenkov
Copy link
Contributor Author

Some questions:

  • Can we skip creating this header in panic=abort mode?
    (Can we link to non-Rust libraries that unwind in panic=abort mode?)
  • If the answer to the first question is "no", then the header will be created for embedded targets as well. Whether they want it?

@Amanieu
Copy link
Member

Amanieu commented Jun 21, 2020

We still need it with unwind=abort because backtraces need unwind info.

@Amanieu
Copy link
Member

Amanieu commented Jun 27, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jun 27, 2020

📌 Commit 79a42e3 has been approved by Amanieu

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 27, 2020
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 29, 2020
linker: Create GNU_EH_FRAME header by default when producing ELFs

Do it in a centralized way in `link.rs` instead of individual target specs.

The opt-out is `-Clink-arg=(-Wl,)--no-eh-frame-hdr` if necessary.

Fixes rust-lang#73451
cc rust-lang#73483
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 30, 2020
linker: Create GNU_EH_FRAME header by default when producing ELFs

Do it in a centralized way in `link.rs` instead of individual target specs.

The opt-out is `-Clink-arg=(-Wl,)--no-eh-frame-hdr` if necessary.

Fixes rust-lang#73451
cc rust-lang#73483
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 2, 2020
…arth

Rollup of 10 pull requests

Successful merges:

 - rust-lang#73414 (Implement `slice_strip` feature)
 - rust-lang#73564 (linker: Create GNU_EH_FRAME header by default when producing ELFs)
 - rust-lang#73622 (Deny unsafe ops in unsafe fns in libcore)
 - rust-lang#73684 (add spans to injected coverage counters, extract with CoverageData query)
 - rust-lang#73812 (ast_pretty: Pass some token streams and trees by reference)
 - rust-lang#73853 (Add newline to rustc MultiSpan docs)
 - rust-lang#73883 (Compile rustdoc less often.)
 - rust-lang#73885 (Fix wasm32 being broken due to a NodeJS version bump)
 - rust-lang#73903 (Changes required for rustc/cargo to build for iOS targets)
 - rust-lang#73938 (Optimise fast path of checked_ops with `unlikely`)

Failed merges:

r? @ghost
@bors bors merged commit 1c68bb6 into rust-lang:master Jul 2, 2020
jclulow added a commit to jclulow/rust that referenced this pull request Jul 8, 2020
As of rust-lang#73564, the --eh-frame-hdr flag is unconditionally
passed to linkers on many platforms.  The illumos link editor does not
currently support this flag.

The linker machinery in the Rust toolchain currently seems to use the
(potentially cross-compiled) target to choose linker flags, rather than
looking at what might be running on the build system.  Disabling the
flag for all illumos/Solaris targets seems like the best we can do for
now without more serious surgery.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 10, 2020
…-fix, r=petrochenkov

linker: illumos ld does not support --eh-frame-hdr

As of rust-lang#73564, the --eh-frame-hdr flag is unconditionally
passed to linkers on many platforms.  The illumos link editor does not
currently support this flag.

The linker machinery in the Rust toolchain currently seems to use the
(potentially cross-compiled) target to choose linker flags, rather than
looking at what might be running on the build system.  Disabling the
flag for all illumos/Solaris targets seems like the best we can do for
now without more serious surgery.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 10, 2020
…-fix, r=petrochenkov

linker: illumos ld does not support --eh-frame-hdr

As of rust-lang#73564, the --eh-frame-hdr flag is unconditionally
passed to linkers on many platforms.  The illumos link editor does not
currently support this flag.

The linker machinery in the Rust toolchain currently seems to use the
(potentially cross-compiled) target to choose linker flags, rather than
looking at what might be running on the build system.  Disabling the
flag for all illumos/Solaris targets seems like the best we can do for
now without more serious surgery.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 10, 2020
…-fix, r=petrochenkov

linker: illumos ld does not support --eh-frame-hdr

As of rust-lang#73564, the --eh-frame-hdr flag is unconditionally
passed to linkers on many platforms.  The illumos link editor does not
currently support this flag.

The linker machinery in the Rust toolchain currently seems to use the
(potentially cross-compiled) target to choose linker flags, rather than
looking at what might be running on the build system.  Disabling the
flag for all illumos/Solaris targets seems like the best we can do for
now without more serious surgery.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 11, 2020
…-fix, r=petrochenkov

linker: illumos ld does not support --eh-frame-hdr

As of rust-lang#73564, the --eh-frame-hdr flag is unconditionally
passed to linkers on many platforms.  The illumos link editor does not
currently support this flag.

The linker machinery in the Rust toolchain currently seems to use the
(potentially cross-compiled) target to choose linker flags, rather than
looking at what might be running on the build system.  Disabling the
flag for all illumos/Solaris targets seems like the best we can do for
now without more serious surgery.
@diodesign
Copy link

diodesign commented Jul 11, 2020

FYI: This breaks, at least, bare-metal Rust RISC-V projects. GNU Binutils doesn't support --eh-frame-hdr nor --no-eh-frame-hdr for RISC-V bare-metal targets, so the opt-out doesn't work. The workaround for bare-metal Rust RISC-V projects is to use Binutils recompiled for riscv32-linux and riscv64-linux targets, and ensure your project's linker script overrides the toolchain's defaults.

I'm commenting here in case anyone else finds their Rust-RISC-V-Binutils toolchain suddenly breaks. I was previously using riscv32-elf and riscv64-elf as a Binutils bare-metal target. I've switched to riscv32-linux and riscv64-linux, and my project builds as expected. If anyone needs any more info, let me know -- happy to help.

Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 11, 2020
…-fix, r=petrochenkov

linker: illumos ld does not support --eh-frame-hdr

As of rust-lang#73564, the --eh-frame-hdr flag is unconditionally
passed to linkers on many platforms.  The illumos link editor does not
currently support this flag.

The linker machinery in the Rust toolchain currently seems to use the
(potentially cross-compiled) target to choose linker flags, rather than
looking at what might be running on the build system.  Disabling the
flag for all illumos/Solaris targets seems like the best we can do for
now without more serious surgery.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 11, 2020
…-fix, r=petrochenkov

linker: illumos ld does not support --eh-frame-hdr

As of rust-lang#73564, the --eh-frame-hdr flag is unconditionally
passed to linkers on many platforms.  The illumos link editor does not
currently support this flag.

The linker machinery in the Rust toolchain currently seems to use the
(potentially cross-compiled) target to choose linker flags, rather than
looking at what might be running on the build system.  Disabling the
flag for all illumos/Solaris targets seems like the best we can do for
now without more serious surgery.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 11, 2020
…-fix, r=petrochenkov

linker: illumos ld does not support --eh-frame-hdr

As of rust-lang#73564, the --eh-frame-hdr flag is unconditionally
passed to linkers on many platforms.  The illumos link editor does not
currently support this flag.

The linker machinery in the Rust toolchain currently seems to use the
(potentially cross-compiled) target to choose linker flags, rather than
looking at what might be running on the build system.  Disabling the
flag for all illumos/Solaris targets seems like the best we can do for
now without more serious surgery.
bors bot added a commit to rust-embedded/riscv-rt that referenced this pull request Jul 15, 2020
62: Preserve .eh_frame and .eh_frame_hdr r=almindor a=Disasm

Preserving the `.eh_frame` section improves gdb stack traces on nightly.
Preserving the `.eh_frame_hdr` section fixes the linker problem `rust-lld: error: no memory region specified for section '.eh_frame_hdr'` introduced in rust-lang/rust#73564

Co-authored-by: Vadim Kaushan <admin@disasm.info>
roxelo pushed a commit to sexxi-goose/rust that referenced this pull request Jul 22, 2020
As of rust-lang#73564, the --eh-frame-hdr flag is unconditionally
passed to linkers on many platforms.  The illumos link editor does not
currently support this flag.

The linker machinery in the Rust toolchain currently seems to use the
(potentially cross-compiled) target to choose linker flags, rather than
looking at what might be running on the build system.  Disabling the
flag for all illumos/Solaris targets seems like the best we can do for
now without more serious surgery.
@petrochenkov
Copy link
Contributor Author

@diodesign
The bare-metal RISC-V targets are fixed in #74631.

Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 22, 2020
rustc_target: Add a target spec option for disabling `--eh-frame-hdr`

Disable `--eh-frame-hdr` for targets that use an `ld`-like linker, but don't support that option.
Do it through a target spec option rather than through hard-coding in `linker.rs`.
The option is still enabled by default though.

cc rust-lang#73564
Fixes rust-lang#73564 (comment)
Fixes rust-lang#74625
Fixes rust-embedded/msp430-rt#12
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 22, 2020
rustc_target: Add a target spec option for disabling `--eh-frame-hdr`

Disable `--eh-frame-hdr` for targets that use an `ld`-like linker, but don't support that option.
Do it through a target spec option rather than through hard-coding in `linker.rs`.
The option is still enabled by default though.

cc rust-lang#73564
Fixes rust-lang#73564 (comment)
Fixes rust-lang#74625
Fixes rust-embedded/msp430-rt#12
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 22, 2020
rustc_target: Add a target spec option for disabling `--eh-frame-hdr`

Disable `--eh-frame-hdr` for targets that use an `ld`-like linker, but don't support that option.
Do it through a target spec option rather than through hard-coding in `linker.rs`.
The option is still enabled by default though.

cc rust-lang#73564
Fixes rust-lang#73564 (comment)
Fixes rust-lang#74625
Fixes rust-embedded/msp430-rt#12
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 22, 2020
rustc_target: Add a target spec option for disabling `--eh-frame-hdr`

Disable `--eh-frame-hdr` for targets that use an `ld`-like linker, but don't support that option.
Do it through a target spec option rather than through hard-coding in `linker.rs`.
The option is still enabled by default though.

cc rust-lang#73564
Fixes rust-lang#73564 (comment)
Fixes rust-lang#74625
Fixes rust-embedded/msp430-rt#12
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 22, 2020
rustc_target: Add a target spec option for disabling `--eh-frame-hdr`

Disable `--eh-frame-hdr` for targets that use an `ld`-like linker, but don't support that option.
Do it through a target spec option rather than through hard-coding in `linker.rs`.
The option is still enabled by default though.

cc rust-lang#73564
Fixes rust-lang#73564 (comment)
Fixes rust-lang#74625
Fixes rust-embedded/msp430-rt#12
romancardenas pushed a commit to rust-embedded/riscv that referenced this pull request Nov 17, 2023
62: Preserve .eh_frame and .eh_frame_hdr r=almindor a=Disasm

Preserving the `.eh_frame` section improves gdb stack traces on nightly.
Preserving the `.eh_frame_hdr` section fixes the linker problem `rust-lld: error: no memory region specified for section '.eh_frame_hdr'` introduced in rust-lang/rust#73564

Co-authored-by: Vadim Kaushan <admin@disasm.info>
@cuviper cuviper added this to the 1.46 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic aborts under rust-lld + musl
7 participants