Created attachment 6102 [details] Test case for secrel32 Attempting to use SECREL32 relocation for generating TLS offsets on Windows works perfectly if the symbol is defined in the object file it is used. However when the symbol is defined in different object file it generates the offset against ".text". The following lines of code appear in coff_i386_rtype_to_howto of bfd/coff-i386.c and I believe should account for that. But it doesn't and I found it odd that h->type was used when similar tests used h->root.type. if (h && (h->type == bfd_link_hash_defined || h->type == bfd_link_hash_defweak)) osect_vma = h->root.u.def.section->output_section->vma; After changing from h->type to h->root.type the problem went away.
Created attachment 6103 [details] Proposed changes.
Created attachment 6104 [details] secrel32.s Included wrong assembly file.
CVSROOT: /cvs/src Module name: src Changes by: amodra@sourceware.org 2012-01-16 08:30:20 Modified files: bfd : ChangeLog coff-i386.c coff-x86_64.c Log message: PR ld/13491 * coff-i386.c (coff_i386_rtype_to_howto <R_SECREL32>): Test h->root.type not h->type. * coff-x86_64.c (coff_amd64_rtype_to_howto <R_AMD64_SECREL>): Likewise. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5587&r2=1.5588 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/coff-i386.c.diff?cvsroot=src&r1=1.35&r2=1.36 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/coff-x86_64.c.diff?cvsroot=src&r1=1.14&r2=1.15
patch applied