| ... | ... | @@ -20,8 +20,6 @@ comptime { |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // TODO this is how I would like it to be expressed |
| 23 | | // TODO also note, ReactOS has a +1 on StartAddressOfRawData and AddressOfCallBacks. Investigate |
| 24 | | // why they do that. |
| 25 | 23 | //export const _tls_used linksection(".rdata$T") = std.os.windows.IMAGE_TLS_DIRECTORY { |
| 26 | 24 | // .StartAddressOfRawData = @intFromPtr(&_tls_start), |
| 27 | 25 | // .EndAddressOfRawData = @intFromPtr(&_tls_end), |
| ... | ... | @@ -35,7 +33,7 @@ pub const IMAGE_TLS_DIRECTORY = extern struct { |
| 35 | 33 | StartAddressOfRawData: *?*anyopaque, |
| 36 | 34 | EndAddressOfRawData: *?*anyopaque, |
| 37 | 35 | AddressOfIndex: *u32, |
| 38 | | AddressOfCallBacks: *windows.PIMAGE_TLS_CALLBACK, |
| 36 | AddressOfCallBacks: [*:null]windows.PIMAGE_TLS_CALLBACK, |
| 39 | 37 | SizeOfZeroFill: u32, |
| 40 | 38 | Characteristics: u32, |
| 41 | 39 | }; |
| ... | ... | @@ -43,7 +41,10 @@ export const _tls_used linksection(".rdata$T") = IMAGE_TLS_DIRECTORY{ |
| 43 | 41 | .StartAddressOfRawData = &_tls_start, |
| 44 | 42 | .EndAddressOfRawData = &_tls_end, |
| 45 | 43 | .AddressOfIndex = &_tls_index, |
| 46 | | .AddressOfCallBacks = &__xl_a, |
| 44 | // __xl_a is just a global variable containing a null pointer; the actual callbacks sit in |
| 45 | // between __xl_a and __xl_z. So we need to skip over __xl_a here. If there are no callbacks, |
| 46 | // this just means we point to __xl_z (the null terminator). |
| 47 | .AddressOfCallBacks = @as([*:null]windows.PIMAGE_TLS_CALLBACK, @ptrCast(&__xl_a)) + 1, |
| 47 | 48 | .SizeOfZeroFill = 0, |
| 48 | 49 | .Characteristics = 0, |
| 49 | 50 | }; |