[llvm-bugs] [Bug 45325] New: Impossible to disable .eh_frame generation with PE/COFF LTO

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 27 02:29:03 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45325

            Bug ID: 45325
           Summary: Impossible to disable .eh_frame generation with
                    PE/COFF LTO
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: vit9696 at avp.su
                CC: llvm-bugs at lists.llvm.org

The issue is similar to clang bug[1], so it is recommended to read it first to
understand the problem.

With LLD the .eh_frame section creation with disabled exceptions is relevant
because of LTO. When LTO is enabled LLD will generate its own functions, and
will thus use the exception model. To configure the exception model in LLD one
can use /mllvm argument (e.g. /mllvm:-exception-model=default). Unfortunately
for LLD the chosen exception model can be anything but disabled once again due
to the defaults[2].

test.c:

void entry() {
}

$ clang -g -fno-builtin -ffunction-sections -fdata-sections -fno-common
-fno-stack-protector -funsigned-char -mno-implicit-float -nostdlib -nostdlibinc
-m32 -Oz -march=i586 -target i686-unknown-windows-gnu -gcodeview
-fno-exceptions -flto -c -o test.obj test.c
$ lld-link /OUT:test.dll /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF
/OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X86 /DLL /ENTRY:entry
/SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /BASE:0 /DEBUG:GHASH /SAFESEH:NO /lldmap
test.obj

To reproduce the problem with currently broken clang one can use
-fseh-exceptions for compilation.

The resolution should probably introduce /mllvm:-exception-model=none argument.
I am not sure how can one implement it best. Now that I think about both bugs,
perhaps it is best to fix the ExceptionHandling enum[3]? Half through the code
None is interpreted as "Default" and gets constantly overridden with other
values coming from e.g. target default. If we rename ExceptionModel::None to
ExceptionModel::Default and introduce a real ExceptionModel::None, then we
could get rid of ugly hacks like this one[4].

I will add a backlink to this bug in #45324, but I guess it will be easier to
discuss it in one place, let's better do it in #45324.

[1] https://bugs.llvm.org/show_bug.cgi?id=45324
[2]
https://github.com/llvm/llvm-project/blob/ac1d23ed7de01fb3a18b340536842a419b504d86/llvm/lib/CodeGen/CommandFlags.cpp#L141-L156
[3]
https://github.com/llvm/llvm-project/blob/ee2c0f76d74cc03e54389926c9e626987e1408c3/llvm/include/llvm/MC/MCTargetOptions.h#L17-L24
[4]
https://github.com/llvm/llvm-project/blob/b61a4aaca5f8a1e71eeaee74d93cdd6fccbef065/llvm/lib/CodeGen/LLVMTargetMachine.cpp#L70-L71

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200327/af9ae921/attachment-0001.html>


More information about the llvm-bugs mailing list