.ARM.exidx woes

Is it possible to force llvm/clang to not create a .ARM.exidx section for a bare-metal application that does not use exceptions? I’ve tried -fno-exceptions -fno-unwind-tables, but it still generates the section with all functions marked as ‘cantunwind’. As a temporary punt I tried linking (using lld) with /DISCARD/ on the section, but that seemed to crash lld, which is another problem for another day. Any suggestions?

RRM

Hello Rob,

I'm not aware of any way to suppress the generation of the .ARM.exidx
section with clang. There is some rationale behind this decision as
having a 'cantunwind' makes it possible to mix such code with code
that uses exceptions and still allow exceptions to propagate through
the subset of the program that has been compiled with exceptions. A
linker should be able to compress all the sections down to a single
entry perhaps with a terminating sentinel so it shouldn't be larger
than 16 bytes. I appreciate that in an embedded system every last byte
counts though.

In LLD we do support discarding the .ARM.exidx, LLD has a --reproduce
option that you could use to file a PR, I'd be happy to take a look at
it. I'd expect /DISCARD/ : { *(.ARM.exidx) *(.ARM.exidx*)
*(.gnu.linkonce.armexidx.*) } to work. LLD hasn't had a lot of
exposure in embedded systems yet, if you do encounter problems please
do raise PRs as we often need real use cases to help guide the
implementation.

Peter

Appreciate the response - explanation makes sense. It might be desirable to have something like ‘-fno-exceptions -fno-unwind-tables’ really kill that section but I won’t push that argument.

As to the lld issue, I was seeing a crash in 6.0.1. This was specifically just using: “/DISCARD/ : { (.ARM.exidx) }”. I tried this morning with 7.0.0 and it did not reproduce, so call it fixed? If you want me to post a reproducible case for 6.0.1, I can.

Thanks again,
RRM

Hello,

Thanks for the update. I can reproduce a crash with LLD 6.0.0 with the
trunk LLD test case so I think it is likely that the problem has only
recently been fixed. I don't think that there will be a 6.0.2 release
so I'm happy to leave it that.

Peter

Hi Rob,

lld has improved significantly in recent years. Version 6.0 was a bit too old, as the most recent release is 7.0.1 and we are about to release lld 8.0. You may see not only a fix for the issue you mentioned but also other improvements in more recent versions. I’d update the linker.