@@ -2435,27 +2435,6 @@ static void set_virtual_addresses_regular(Context<E> &ctx) {
2435
2435
std::vector<Chunk<E> *> &chunks = ctx.chunks ;
2436
2436
u64 addr = ctx.arg .image_base ;
2437
2437
2438
- // TLS chunks alignments are special: in addition to having their virtual
2439
- // addresses aligned, they also have to be aligned when the region of
2440
- // tls_begin is copied to a new thread's storage area. In other words, their
2441
- // offset against tls_begin also has to be aligned.
2442
- //
2443
- // A good way to achieve this is to take the largest alignment requirement
2444
- // of all TLS sections and make tls_begin also aligned to that.
2445
- Chunk<E> *first_tls_chunk = nullptr ;
2446
- u64 tls_alignment = 1 ;
2447
- for (Chunk<E> *chunk : chunks) {
2448
- if (chunk->shdr .sh_flags & SHF_TLS) {
2449
- if (!first_tls_chunk)
2450
- first_tls_chunk = chunk;
2451
- tls_alignment = std::max (tls_alignment, (u64)chunk->shdr .sh_addralign );
2452
- }
2453
- }
2454
-
2455
- auto alignment = [&](Chunk<E> *chunk) {
2456
- return chunk == first_tls_chunk ? tls_alignment : (u64)chunk->shdr .sh_addralign ;
2457
- };
2458
-
2459
2438
auto is_tbss = [](Chunk<E> *chunk) {
2460
2439
return (chunk->shdr .sh_type == SHT_NOBITS) && (chunk->shdr .sh_flags & SHF_TLS);
2461
2440
};
@@ -2527,7 +2506,7 @@ static void set_virtual_addresses_regular(Context<E> &ctx) {
2527
2506
if (is_tbss (chunks[i])) {
2528
2507
u64 addr2 = addr;
2529
2508
for (;;) {
2530
- addr2 = align_to (addr2, alignment ( chunks[i]) );
2509
+ addr2 = align_to (addr2, chunks[i]-> shdr . sh_addralign );
2531
2510
chunks[i]->shdr .sh_addr = addr2;
2532
2511
addr2 += chunks[i]->shdr .sh_size ;
2533
2512
if (i + 2 == chunks.size () || !is_tbss (chunks[i + 1 ]))
@@ -2537,7 +2516,7 @@ static void set_virtual_addresses_regular(Context<E> &ctx) {
2537
2516
continue ;
2538
2517
}
2539
2518
2540
- addr = align_to (addr, alignment ( chunks[i]) );
2519
+ addr = align_to (addr, chunks[i]-> shdr . sh_addralign );
2541
2520
chunks[i]->shdr .sh_addr = addr;
2542
2521
addr += chunks[i]->shdr .sh_size ;
2543
2522
}
0 commit comments