<div dir="ltr">Is that the only problem to use lld to link cygwin programs?</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 8, 2018 at 8:19 AM, Andrew Kelley <span dir="ltr"><<a href="mailto:superjoe30@gmail.com" target="_blank">superjoe30@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Here are the linker errors:<br><br>lld: warning: libcygwin.a(_cygwin_crt0_<wbr>common.o): undefined symbol: __data_start__<br>lld: warning: libcygwin.a(_cygwin_crt0_<wbr>common.o): undefined symbol: __data_end__<br>lld: warning: libcygwin.a(_cygwin_crt0_<wbr>common.o): undefined symbol: __bss_start__<br>lld: warning: libcygwin.a(_cygwin_crt0_<wbr>common.o): undefined symbol: __bss_end__<br>lld: warning: libcygwin.a(_cygwin_crt0_<wbr>common.o): undefined symbol: __RUNTIME_PSEUDO_RELOC_LIST__<br>lld: warning: libcygwin.a(_cygwin_crt0_<wbr>common.o): undefined symbol: __RUNTIME_PSEUDO_RELOC_LIST_<wbr>END__<br>lld: warning: libcygwin.a(_cygwin_crt0_<wbr>common.o): undefined symbol: __image_base__<br><br></div><br></div>They seem to come from the default cygwin ld linker script, pasted below:<br><br>GNU ld (GNU Binutils) 2.29.1.20171006<br>  Supported emulations:<br>   i386pep<br>   i386pe<br>using internal linker script:<br>==============================<wbr>====================<br>/* Default linker script, for normal executables */<br>/* Copyright (C) 2014-2017 Free Software Foundation, Inc.<br>   Copying and distribution of this script, with or without modification,<br>   are permitted in any medium without royalty provided the copyright<br>   notice and this notice are preserved.  */<br>OUTPUT_FORMAT(pei-x86-64)<br>SEARCH_DIR("/usr/x86_64-pc-<wbr>cygwin/lib"); SEARCH_DIR("/usr/lib"); SEARCH_DIR("/usr/lib/w32api");<br>SECTIONS<br>{<br>  /* Make the virtual address and file offset synced if the alignment is<br>     lower than the target page size. */<br>  . = SIZEOF_HEADERS;<br>  . = ALIGN(__section_alignment__);<br>  .text  __image_base__ + ( __section_alignment__ < 0x1000 ? . : __section_alignment__ ) :<br>  {<br>     KEEP(*(.init))<br>    *(.text)<br>    *(SORT(.text$*))<br>     *(.text.*)<br>     *(.gnu.linkonce.t.*)<br>    *(.glue_7t)<br>    *(.glue_7)<br>    . = ALIGN(8);<br>     ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;<br>            LONG (-1); LONG (-1);<br>            KEEP (*(.ctors));<br>            KEEP (*(.ctor));<br>            KEEP (*(SORT(.ctors.*)));<br>            LONG (0); LONG (0);<br>     ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;<br>            LONG (-1); LONG (-1);<br>            KEEP (*(.dtors));<br>            KEEP (*(.dtor));<br>            KEEP (*(SORT(.dtors.*)));<br>            LONG (0); LONG (0);<br>     KEEP (*(.fini))<br>    /* ??? Why is .gcc_exc here?  */<br>     *(.gcc_exc)<br>    PROVIDE (etext = .);<br>     KEEP (*(.gcc_except_table))<br>  }<br>  /* The Cygwin32 library uses a section to avoid copying certain data<br>     on fork.  This used to be named ".data".  The linker used<br>     to include this between __data_start__ and __data_end__, but that<br>     breaks building the cygwin32 dll.  Instead, we name the section<br>     ".data_cygwin_nocopy" and explicitly include it after __data_end__. */<br>  .data BLOCK(__section_alignment__) :<br>  {<br>    __data_start__ = . ;<br>    *(.data)<br>    *(.data2)<br>    *(SORT(.data$*))<br>    KEEP(*(.jcr))<br>    __data_end__ = . ;<br>    *(.data_cygwin_nocopy)<br>  }<br>  .rdata BLOCK(__section_alignment__) :<br>  {<br>    *(.rdata)<br>             *(SORT(.rdata$*))<br>    __rt_psrelocs_start = .;<br>    KEEP(*(.rdata_runtime_pseudo_<wbr>reloc))<br>    __rt_psrelocs_end = .;<br>  }<br>  __rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;<br>  ___RUNTIME_PSEUDO_RELOC_LIST_<wbr>END__ = .;<br>  __RUNTIME_PSEUDO_RELOC_LIST_<wbr>END__ = .;<br>  ___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;<br>  __RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;<br>  .eh_frame BLOCK(__section_alignment__) :<br>  {<br>    KEEP (*(.eh_frame*))<br>  }<br>  .pdata BLOCK(__section_alignment__) :<br>  {<br>    KEEP(*(.pdata*))<br>  }<br>  .xdata BLOCK(__section_alignment__) :<br>  {<br>    KEEP(*(.xdata*))<br>  }<br>  .bss BLOCK(__section_alignment__) :<br>  {<br>    __bss_start__ = . ;<br>    *(.bss)<br>    *(COMMON)<br>    __bss_end__ = . ;<br>  }<br>  .edata BLOCK(__section_alignment__) :<br>  {<br>    *(.edata)<br>  }<br>  /DISCARD/ :<br>  {<br>    *(.debug$S)<br>    *(.debug$T)<br>    *(.debug$F)<br>    *(.drectve)<br>     *(.note.GNU-stack)<br>     *(.gnu.lto_*)<br>  }<br>  .idata BLOCK(__section_alignment__) :<br>  {<br>    /* This cannot currently be handled with grouped sections.<br>    See pep.em:sort_sections.  */<br>    KEEP (SORT(*)(.idata$2))<br>    KEEP (SORT(*)(.idata$3))<br>    /* These zeroes mark the end of the import list.  */<br>    LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);<br>    KEEP (SORT(*)(.idata$4))<br>    __IAT_start__ = .;<br>    SORT(*)(.idata$5)<br>    __IAT_end__ = .;<br>    KEEP (SORT(*)(.idata$6))<br>    KEEP (SORT(*)(.idata$7))<br>  }<br>  .CRT BLOCK(__section_alignment__) :<br>  {<br>    ___crt_xc_start__ = . ;<br>    KEEP (*(SORT(.CRT$XC*)))  /* C initialization */<br>    ___crt_xc_end__ = . ;<br>    ___crt_xi_start__ = . ;<br>    KEEP (*(SORT(.CRT$XI*)))  /* C++ initialization */<br>    ___crt_xi_end__ = . ;<br>    ___crt_xl_start__ = . ;<br>    KEEP (*(SORT(.CRT$XL*)))  /* TLS callbacks */<br>    /* ___crt_xl_end__ is defined in the TLS Directory support code */<br>    ___crt_xp_start__ = . ;<br>    KEEP (*(SORT(.CRT$XP*)))  /* Pre-termination */<br>    ___crt_xp_end__ = . ;<br>    ___crt_xt_start__ = . ;<br>    KEEP (*(SORT(.CRT$XT*)))  /* Termination */<br>    ___crt_xt_end__ = . ;<br>  }<br>  /* Windows TLS expects .tls$AAA to be at the start and .tls$ZZZ to be<br>     at the end of the .tls section.  This is important because _tls_start MUST<br>     be at the beginning of the section to enable SECREL32 relocations with TLS<br>     data.  */<br>  .tls BLOCK(__section_alignment__) :<br>  {<br>    ___tls_start__ = . ;<br>    KEEP (*(.tls$AAA))<br>    KEEP (*(.tls))<br>    KEEP (*(.tls$))<br>    KEEP (*(SORT(.tls$*)))<br>    KEEP (*(.tls$ZZZ))<br>    ___tls_end__ = . ;<br>  }<br>  .endjunk BLOCK(__section_alignment__) :<br>  {<br>    /* end is deprecated, don't use it */<br>    PROVIDE (end = .);<br>    PROVIDE ( _end = .);<br>     __end__ = .;<br>  }<br>  .rsrc BLOCK(__section_alignment__) : SUBALIGN(4)<br>  {<br>    KEEP (*(.rsrc))<br>    KEEP (*(.rsrc$*))<br>  }<br>  .reloc BLOCK(__section_alignment__) :<br>  {<br>    *(.reloc)<br>  }<br>  .stab BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.stab)<br>  }<br>  .stabstr BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.stabstr)<br>  }<br>  /* DWARF debug sections.<br>     Symbols in the DWARF debugging sections are relative to the beginning<br>     of the section.  Unlike other targets that fake this by putting the<br>     section VMA at 0, the PE format will not allow it.  */<br>  /* DWARF 1.1 and DWARF 2.  */<br>  .debug_aranges BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_aranges)<br>  }<br>  .zdebug_aranges BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_aranges)<br>  }<br>  .debug_pubnames BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_pubnames)<br>  }<br>  .zdebug_pubnames BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_pubnames)<br>  }<br>  .debug_pubtypes BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_pubtypes)<br>  }<br>  .zdebug_pubtypes BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_pubtypes)<br>  }<br>  /* DWARF 2.  */<br>  .debug_info BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_info .gnu.linkonce.wi.*)<br>  }<br>  .zdebug_info BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_info .zdebug.gnu.linkonce.wi.*)<br>  }<br>  .debug_abbrev BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_abbrev)<br>  }<br>  .zdebug_abbrev BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_abbrev)<br>  }<br>  .debug_line BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_line)<br>  }<br>  .zdebug_line BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_line)<br>  }<br>  .debug_frame BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_frame)<br>  }<br>  .zdebug_frame BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_frame)<br>  }<br>  .debug_str BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_str)<br>  }<br>  .zdebug_str BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_str)<br>  }<br>  .debug_loc BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_loc)<br>  }<br>  .zdebug_loc BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_loc)<br>  }<br>  .debug_macinfo BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_macinfo)<br>  }<br>  .zdebug_macinfo BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_macinfo)<br>  }<br>  /* SGI/MIPS DWARF 2 extensions.  */<br>  .debug_weaknames BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_weaknames)<br>  }<br>  .zdebug_weaknames BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_weaknames)<br>  }<br>  .debug_funcnames BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_funcnames)<br>  }<br>  .zdebug_funcnames BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_funcnames)<br>  }<br>  .debug_typenames BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_typenames)<br>  }<br>  .zdebug_typenames BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_typenames)<br>  }<br>  .debug_varnames BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_varnames)<br>  }<br>  .zdebug_varnames BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_varnames)<br>  }<br>  .debug_macro BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_macro)<br>  }<br>  .zdebug_macro BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_macro)<br>  }<br>  /* DWARF 3.  */<br>  .debug_ranges BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_ranges)<br>  }<br>  .zdebug_ranges BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_ranges)<br>  }<br>  /* DWARF 4.  */<br>  .debug_types BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_types .gnu.linkonce.wt.*)<br>  }<br>  .zdebug_types BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_types .zdebug.gnu.linkonce.wt.*)<br>  }<br>  /* For Go and Rust.  */<br>  .debug_gdb_scripts BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.debug_gdb_scripts)<br>  }<br>  .zdebug_gdb_scripts BLOCK(__section_alignment__) (NOLOAD) :<br>  {<br>    *(.zdebug_gdb_scripts)<br>  }<br>}<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 7, 2018 at 6:24 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">COFF lld doesn't support the linker script at the moment, and I'm sad to say that it is very unlikely to support that in the future. Linker script support is so huge that I can't imagine we really want it for COFF. GNU BFD linker supports it because the linker is built as an interpreter for the built-in linker script (and that's one of the reasons why GNU linker is by far more complicated than lld), but that's not the case for lld.<div><div><br></div><div>So, "support linker script" is a huge feature request that we are very unlikely to fulfill. But I don't think that you actually need all the features of the linker script. If you have some specific need, please explain. We may be able to help.</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-730019277705376480h5">On Wed, Feb 7, 2018 at 3:10 PM, Andrew Kelley via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-730019277705376480h5"><div dir="ltr"><div><div><div>Hello, I have a user who is trying to get LLD to link for the cygwin target: <a href="https://github.com/zig-lang/zig/issues/751" target="_blank">https://github.com/zig-lang/zi<wbr>g/issues/751</a><br><br></div>Currently the issue they are running into is needing to define a linker script, but the COFF driver (or MinGW driver) does not have support for that.<br><br></div>Is there documentation or advice for how to use LLD to link for cygwin? As a starting point, which driver to use?<br></div><div><br></div><div>Regards,</div><div>Andrew<br></div></div>
<br></div></div>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>