| ... | @@ -313,7 +313,7 @@ fn computeAreaDesc(phdrs: []elf.Phdr) void { | ... | @@ -313,7 +313,7 @@ fn computeAreaDesc(phdrs: []elf.Phdr) void { |
| 313 | // Compute the total size of the ABI-specific data plus our own `ZigTcb` structure. All the | 313 | // Compute the total size of the ABI-specific data plus our own `ZigTcb` structure. All the |
| 314 | // offsets calculated here assume a well-aligned base address. | 314 | // offsets calculated here assume a well-aligned base address. |
| 315 | const area_size = switch (current_variant) { | 315 | const area_size = switch (current_variant) { |
| 316 | .I_original, .I_modified => blk: { | 316 | .I_original => blk: { |
| 317 | var l: usize = 0; | 317 | var l: usize = 0; |
| 318 | dtv_offset = l; | 318 | dtv_offset = l; |
| 319 | l += @sizeOf(Dtv); | 319 | l += @sizeOf(Dtv); |
| ... | @@ -330,6 +330,24 @@ fn computeAreaDesc(phdrs: []elf.Phdr) void { | ... | @@ -330,6 +330,24 @@ fn computeAreaDesc(phdrs: []elf.Phdr) void { |
| 330 | l += block_size; | 330 | l += block_size; |
| 331 | break :blk l; | 331 | break :blk l; |
| 332 | }, | 332 | }, |
| | 333 | .I_modified => blk: { |
| | 334 | var l: usize = 0; |
| | 335 | dtv_offset = l; |
| | 336 | l += @sizeOf(Dtv); |
| | 337 | // In this variant, the TLS blocks must begin immediately after the end of the ABI TCB, |
| | 338 | // with the TP pointing to the beginning of the TLS blocks. Add padding so that the TP |
| | 339 | // (`abi_tcb_offset`) is aligned to `align_factor` and the `ZigTcb` structure can be |
| | 340 | // found by subtracting `@sizeOf(AbiTcb) + @sizeOf(ZigTcb)` from the TP. |
| | 341 | const delta = (l + @sizeOf(ZigTcb) + @sizeOf(AbiTcb)) & (align_factor - 1); |
| | 342 | if (delta > 0) |
| | 343 | l += align_factor - delta; |
| | 344 | l += @sizeOf(ZigTcb); |
| | 345 | abi_tcb_offset = l; |
| | 346 | l += @sizeOf(AbiTcb); |
| | 347 | block_offset = l; |
| | 348 | l += block_size; |
| | 349 | break :blk l; |
| | 350 | }, |
| 333 | .II => blk: { | 351 | .II => blk: { |
| 334 | var l: usize = 0; | 352 | var l: usize = 0; |
| 335 | block_offset = l; | 353 | block_offset = l; |