[llvm-dev] lld error: output file too large <some large number>

Moshtaghi, Alireza via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 16 10:31:39 PST 2020


Actually it is the combination of -Ttext 0x0 and --no-rosegment that cause the problem. You can reproduce using any c file using following:
clang test.c -fuse-ld=lld -Wl,-Ttext,0x0 -Wl,--no-rosegment

A

On 11/16/20, 9:52 AM, "llvm-dev on behalf of Moshtaghi, Alireza via llvm-dev" <llvm-dev-bounces at lists.llvm.org on behalf of llvm-dev at lists.llvm.org> wrote:

    NetApp Security WARNING: This is an external email. Do not click links or open attachments unless you recognize the sender and know the content is safe.




    I can't send the exact objects, but I'll try to reproduce.

    Thanks
    A

    On 11/16/20, 9:48 AM, "Fāng-ruì Sòng" <maskray at google.com> wrote:

        NetApp Security WARNING: This is an external email. Do not click links or open attachments unless you recognize the sender and know the content is safe.




        On Mon, Nov 16, 2020 at 9:05 AM Moshtaghi, Alireza
        <Alireza.Moshtaghi at netapp.com> wrote:
        >
        > My target requires that text section be at 0x0 so "-Ttext 0x0" is passed to the linker.
        > When I link with gold, it goes through; but lld fails.
        > Instead of always returning the same calculation, when I change the calculation to the following, it links:
        >   return first->offset + (os->addr > first->addr ?
        >                           os->addr - first->addr :
        >                           os->addr);
        >
        > There are other things in the build that I need to fix so I can't tell if the result is correct yet though. Do you think this is correct?

        It is wrong. Can you upload a reproduce file somewhere?
        (LLD_REPRODUCE=/tmp/rep.tar ld.lld ....   or ld.lld
        --reproduce=/tmp/rep.tar)

        > Thanks
        > A
        >
        > On 11/15/20, 11:19 PM, "Fāng-ruì Sòng" <maskray at google.com> wrote:
        >
        >     NetApp Security WARNING: This is an external email. Do not click links or open attachments unless you recognize the sender and know the content is safe.
        >
        >
        >
        >
        >     Hi Alireza, getFileAlignment was renamed in Oct 2018. It seems that
        >     you may have sectionA and sectionB in one PT_LOAD while sectionB has a
        >     lower address. This is invalid.
        >
        >     Can you provide more information about how you have a sectionB with a
        >     lower address? Note that LLD has an error "unable to move location
        >     counter backward for: ".
        >
        >     On Sun, Nov 15, 2020 at 12:20 AM Moshtaghi, Alireza via llvm-dev
        >     <llvm-dev at lists.llvm.org> wrote:
        >     >
        >     > Hi
        >     >
        >     > I’m having a trouble linking a special program with lld and the above error is generated.
        >     >
        >     > I narrowed it down to lld/Writer.cpp:getFileAlignment ().
        >     >
        >     > (Well, my local repository is from a while back (version 10) and for me it is lld/Writer.cpp:computeFileOffset ())
        >     >
        >     > Either way, where it is calculating the file offset when two sections share same PT_LOAD, the formula used is off2 = off1 + (VA2 – VA1) but the subtraction is causing a negative number, causing out of bound value…
        >     >
        >     >
        >     >
        >     > Should this be abs(VA2 – VA1) ?
        >     >
        >     > Or
        >     >
        >     > Should it be cast to a signed integer so we subtract the difference rather than adding the large value?
        >     >
        >     >
        >     >
        >     > Thanks
        >     >
        >     > A.
        >     >
        >     > _______________________________________________
        >     > LLVM Developers mailing list
        >     > llvm-dev at lists.llvm.org
        >     > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
        >
        >
        >
        >     --
        >     宋方睿
        >


        --
        宋方睿

    _______________________________________________
    LLVM Developers mailing list
    llvm-dev at lists.llvm.org
    https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list