[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 12:57:00 PST 2020


Thanks for the information.
After reading https://bugs.llvm.org/show_bug.cgi?id=44715 I think I need to find another way to do this.

A

On 11/16/20, 10:39 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.




    This is a common pitfall: people think that .text is the first section
    of the traditional concept "text segment" (which does not apply with
    LLD layout and GNU ld's -z separate-code layout)
    You need to use --image-base=0

    https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html#breaking-changes

    On Mon, Nov 16, 2020 at 10:31 AM Moshtaghi, Alireza
    <Alireza.Moshtaghi at netapp.com> wrote:
    >
    > 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