This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
finally got the TLS directory to output but its outputing the wrongaddress
- From: Jonathan Wilson <jonwil at tpgi dot com dot au>
- To: binutils at sources dot redhat dot com
- Date: Wed, 15 Oct 2003 15:32:52 +0800
- Subject: finally got the TLS directory to output but its outputing the wrongaddress
What it should be outputting is the address of the symbol relative to the
start of the on-disk exe file (as opposed to the in-memory location).
I cant figure out how to do that though (even after staring at the various
data structures all afternoon)
Someone want to help me with this last bit?
Then, I test it and make sure it works.
Then, its on to the GCC part of the TLS support.
Index: peXXigen.c
===================================================================
RCS file: /cvs/src/src/bfd/peXXigen.c,v
retrieving revision 1.16
diff -u -r1.16 peXXigen.c
--- peXXigen.c 7 Oct 2003 08:49:11 -0000 1.16
+++ peXXigen.c 15 Oct 2003 07:23:22 -0000
@@ -570,7 +570,7 @@
struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
PEAOUTHDR *aouthdr_out = (PEAOUTHDR *) out;
bfd_vma sa, fa, ib;
- IMAGE_DATA_DIRECTORY idata2, idata5;
+ IMAGE_DATA_DIRECTORY idata2, idata5, tls;
if (pe->force_minimum_alignment)
@@ -589,7 +589,8 @@
ib = extra->ImageBase;
idata2 = pe->pe_opthdr.DataDirectory[1];
- idata5 = pe->pe_opthdr.DataDirectory[12];
+ idata5 = pe->pe_opthdr.DataDirectory[12];
+ tls = pe->pe_opthdr.DataDirectory[9];
if (aouthdr_in->tsize)
{
@@ -640,7 +641,8 @@
So - we copy the input values into the output values, and then, if
a final link is going to be performed, it can overwrite them. */
extra->DataDirectory[1] = idata2;
- extra->DataDirectory[12] = idata5;
+ extra->DataDirectory[12] = idata5;
+ extra->DataDirectory[9] = tls;
if (extra->DataDirectory[1].VirtualAddress == 0)
/* Until other .idata fixes are made (pending patch), the entry for
@@ -2024,7 +2026,17 @@
- pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress);
}
- /* If we couldn't find idata$2, we either have an excessively
+ h1 = coff_link_hash_lookup (coff_hash_table (info),
+ "__tls_used", FALSE, FALSE, TRUE);
+ if (h1 != NULL)
+ {
+ pe_data (abfd)->pe_opthdr.DataDirectory[9].VirtualAddress =
+ (h1->root.u.def.value
+ + h1->root.u.def.section->output_section->lma
+ + h1->root.u.def.section->output_offset);
+ pe_data (abfd)->pe_opthdr.DataDirectory[9].Size = 0x18;
+ }
+ /* If we couldn't find idata$2, we either have an excessively
trivial program or are in DEEP trouble; we have to assume trivial
program.... */
return TRUE;