.eh_frame_hdr is a header constructed for .eh_frame sections.
We do not proccess .eh_frame when doing relocatable output,
so should not try to create .eh_frame_hdr too.
Previous behavior without this patch is segfault.
Fixes PR32118.
Differential D30566
[ELF] - Do not try to create .eh_frame_hdr for relocatable output. grimar on Mar 3 2017, 3:16 AM. Authored by
Details .eh_frame_hdr is a header constructed for .eh_frame sections. Fixes PR32118.
Diff Detail
Event TimelineComment Actions Personally, I think that there should be a warning or error about incompatible command-line options in this case. A user has explicitly requested two different features that cannot be used together. We should tell them that -r wins out over --eh-frame-hdr. I think it would make sense to put the test inside the same test as the normal .eh_frame_hdr test. That way we know for certain that an .eh_frame_hdr would definitely be created if -r was not specified, and that we aren't getting a spurious pass. Comment Actions
In this case the user explicitly requested -r, and the compiler driver implicitly added --eh-frame-hdr. A sample command line that leads to this error: cc -target x86_64-unknown-freebsd12.0 --sysroot=/tank/emaste/obj/tank/emaste/src/freebsd-xlld/tmp -B/tank/emaste/obj/tank/emaste/src/freebsd-xlld/tmp/usr/bin -O2 -pipe -std=gnu99 -Qunused-arguments -nostdlib -Wl,-dc -r -o cat.lo cat_stub.o /tank/emaste/obj/tank/emaste/src/freebsd-xlld/rescue/rescue//tank/emaste/src/freebsd-xlld/bin/cat/cat.o It may well be the case that we should (also) change Clang to not add --eh-frame-hdr on relocatable links. Comment Actions The FreeBSD components that prompted PR32118 link with this change. Unable to test full image as lld now fails an assertion later in the build - PR to follow. /tank/emaste/obj/tank/emaste/src/freebsd-xlld/tmp/usr/bin/ld: error: Section has different type from others with the same name autoload.o:(.eh_frame) Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file ../include/llvm/Support/Casting.h, line 236. cc: error: unable to execute command: Abort trap (core dumped) cc: error: linker command failed due to signal (use -v to see invocation) Comment Actions I'm not sure that clang should care at all about relocatable output, it is too much of a special case. IMO if you want to link relocatable output, you should call the linker directly. Comment Actions
That's probably true and something we should address in FreeBSD's build. However, this is a regression from 4.0.0 so perhaps we should initially go with this D30566 patch in addition to a warning that --eh-frame-header is being ignored? Comment Actions I probably would not do that. Normal .eh_frame_hdr test is a "eh-frame-hdr.s" for example, it is itself complete and large enough. Comment Actions Fair enough, since there's prior art for this. Looks good from my point of view, but should probably get a LGTM from somebody with a little more familiarity with the code-base.
|