Boost logo

Boost :

From: Aaron W. LaFramboise (aaronrabiddog51_at_[hidden])
Date: 2004-08-05 12:43:11


Roland wrote:
> After having unified your and my code and having compared MSVC& and 7
> I came to the following observations so far:
>
> 1) MSVC6:
> The linker creates a named data segemnet when requested by the object
> that has a minimumsize of 260 Bytes. Then it assembles the pointer(s)
into this segement.
> In the result the sequence:

I positively cannot account for the behavior you are seeing. This does
not happen for me. Perhaps it was a bug on an earlier version of MSVC6.
 For reference, CL reports version 12.00.8168 and LINK reports version
6.00.8168.

In any case, if the following source file is added to the compile line
(to replace the broken tlssup.obj in the runtime library), TLS callbacks
work correctly on my copy of MSVC6 as they do on MSVC7.1:

---msvc_tls.cpp---
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

namespace {

#pragma const_seg(".tls")
extern const LONGLONG _tls_start = 0;
#pragma const_seg(".tls$ZZZ")
extern const LONGLONG _tls_end = 0;
#pragma const_seg()

} // namespace

extern "C" {

#pragma data_seg(".CRT$XLA")
PIMAGE_TLS_CALLBACK __xl_a = 0;
#pragma data_seg(".CRT$XLZ")
PIMAGE_TLS_CALLBACK __xl_z = 0;
#pragma data_seg()

DWORD _tls_index;

extern const IMAGE_TLS_DIRECTORY _tls_used = {
  reinterpret_cast<DWORD>(&_tls_start),
  reinterpret_cast<DWORD>(&_tls_end),
  &_tls_index,
  &__xl_a + 1,
  0,
  0
};

} // extern "C"
---EOF---

If this does not work for you, then there must be some other problem,
such as a linker bug as you mention, that does not occur on my MSVC6
installation.

At any rate, I think your suggested implementation is the way to go as
it gets everything right and works everywhere. :)

Aaron W. LaFramboise


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk