[PATCH v2] ld: Load the object only section when opening the mixed object file

H.J. Lu hjl.tools@gmail.com
Fri Jan 17 02:04:20 GMT 2025


On Fri, Jan 17, 2025 at 7:40 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Tue, Jan 14, 2025 at 11:59 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > Since only mixed LTO and none-LTO relocatable output is only supported
> > on ELF platforms, limit these tests to ELF targets.  Since powerpc64
> > elfv1 defines a function symbol on its procedure descriptor, which is in
> > a data section, rather than on the code for that function, allow both D
> > and T for nm test on mixed object.
> >
>
> It turns out that mixed LTO and non-LTO relocatable output works for
> non-ELF targets.  The issue is that the object only section is loaded
> after all other input files have been loaded.  This caused:
>
> .../ld/collect-ld: /tmp/ccZAoUIW.obj-only.o: in function `main':
> .../ld/testsuite/ld-plugin/lto-10a.c:4: multiple definition of `main';
> /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o):(.text.startup+0x0):
> first defined here
> .../ld/collect-ld:
> /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o):(.text.startup+0xc5):
> undefined reference to `WinMain'
> collect2: error: ld returned 1 exit status
> ...
> FAIL: LTO 10
>
> for x86_64-w64-mingw32.
>
> Load the object only section when opening the mixed object file, instead
> of loading it after all other input files have been loaded, fixed it.   Here is
> the patch.
>
> H.J.

There is the v2 patch to remove "On ELF platforms" from documentation of
mixing LTO and non-LTO relocatable files for "ld -r".

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-ld-Load-the-object-only-section-when-opening-the-.patch
Type: text/x-patch
Size: 8816 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20250117/17bd81e0/attachment-0001.bin>


More information about the Binutils mailing list