Index: ld/scripttempl/pe.sc =================================================================== RCS file: /cvs/src/src/ld/scripttempl/pe.sc,v retrieving revision 1.29 diff -u -p -r1.29 pe.sc --- ld/scripttempl/pe.sc 27 Sep 2011 15:59:55 -0000 1.29 +++ ld/scripttempl/pe.sc 16 Jan 2012 17:07:59 -0000 @@ -39,9 +39,11 @@ if test "${RELOCATING}"; then R_CRT_XP='*(SORT(.CRT$XP*)) /* Pre-termination */' R_CRT_XT='*(SORT(.CRT$XT*)) /* Termination */' R_TLS=' + *(.tls$AAA) *(.tls) *(.tls$) - *(SORT(.tls$*))' + *(SORT(.tls$*)) + *(.tls$ZZZ)' R_RSRC='*(SORT(.rsrc$*))' else R_TEXT= @@ -179,6 +181,10 @@ SECTIONS ${RELOCATING+___crt_xt_end__ = . ;} } + /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be + at the end of section. This is important because _tls_start MUST + be at the beginning of the section to enable SECREL32 relocations with TLS + data. */ .tls ${RELOCATING+BLOCK(__section_alignment__)} : { ${RELOCATING+___tls_start__ = . ;} Index: ld/scripttempl/pep.sc =================================================================== RCS file: /cvs/src/src/ld/scripttempl/pep.sc,v retrieving revision 1.18 diff -u -p -r1.18 pep.sc --- ld/scripttempl/pep.sc 27 Sep 2011 15:59:55 -0000 1.18 +++ ld/scripttempl/pep.sc 16 Jan 2012 17:07:59 -0000 @@ -39,9 +39,11 @@ if test "${RELOCATING}"; then R_CRT_XP='*(SORT(.CRT$XP*)) /* Pre-termination */' R_CRT_XT='*(SORT(.CRT$XT*)) /* Termination */' R_TLS=' + *(.tls$AAA) *(.tls) *(.tls$) - *(SORT(.tls$*))' + *(SORT(.tls$*)) + *(.tls$ZZZ)' R_RSRC='*(SORT(.rsrc$*))' else R_TEXT= @@ -185,6 +187,10 @@ SECTIONS ${RELOCATING+___crt_xt_end__ = . ;} } + /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be + at the end of the .tls section. This is important because _tls_start MUST + be at the beginning of the section to enable SECREL32 relocations with TLS + data. */ .tls ${RELOCATING+BLOCK(__section_alignment__)} : { ${RELOCATING+___tls_start__ = . ;}