File tree Expand file tree Collapse file tree 5 files changed +57
-8
lines changed
test/Common/standalone/TLS/OnlyTBSS Expand file tree Collapse file tree 5 files changed +57
-8
lines changed Original file line number Diff line number Diff line change @@ -369,15 +369,16 @@ bool GNULDBackend::createProgramHdrs() {
369369 if (config ().options ().isOMagic ())
370370 cur_flag = (cur_flag & ~llvm::ELF::PF_W);
371371
372- // getSegmentFlag returns 0 if the section is not allocatable.
373- if ((cur_flag != prev_flag) && (isCurAlloc))
374- createPT_LOAD = true ;
372+ if (!cur-> isTBSS ()) {
373+ if ((cur_flag != prev_flag) && (isCurAlloc))
374+ createPT_LOAD = true ;
375375
376- if (linkerScriptHasMemoryCommand && (cur_mem_region != prev_mem_region))
377- createPT_LOAD = true ;
376+ if (linkerScriptHasMemoryCommand && (cur_mem_region != prev_mem_region))
377+ createPT_LOAD = true ;
378378
379- if (linkerScriptHasMemoryCommand && (cur_mem_region != prev_mem_region))
380- createPT_LOAD = true ;
379+ if (linkerScriptHasMemoryCommand && (cur_mem_region != prev_mem_region))
380+ createPT_LOAD = true ;
381+ }
381382
382383 // If the current section is alloc section and if the previous section is
383384 // NOBITS and current is PROGBITS, we need to create a new segment.
@@ -408,7 +409,7 @@ bool GNULDBackend::createProgramHdrs() {
408409
409410 // If Program headers are not specified and the vma difference is big
410411 // lets create a PT_LOAD to adjust the offset.
411- if (std::abs (vmaoffset) > (int64_t )segAlign)
412+ if (( std::abs (vmaoffset) > (int64_t )segAlign) && (!cur-> isTBSS ()) )
412413 createPT_LOAD = true ;
413414 }
414415 }
Original file line number Diff line number Diff line change 1+ MEMORY
2+ {
3+ RAM (rw ) : ORIGIN = 10000 , LENGTH = 5000
4+ }
5+
6+ SECTIONS {
7+ . foo : { * (. text. foo) } > RAM
8+ . empty : {} > RAM
9+ tbss : { * (. tbss* ) } > RAM
10+ . empty : {} > RAM
11+ . main : { * (. text. main) } > RAM
12+ output_data : { BYTE(0x0 ) * (. data* ) } > RAM
13+ /DISCARD / : { * (. riscv. attributes ) }
14+ }
Original file line number Diff line number Diff line change 1+ MEMORY
2+ {
3+ RAM (rw ) : ORIGIN = 10000 , LENGTH = 5000
4+ ROM (rw ) : ORIGIN = 20000 , LENGTH = 5000
5+ }
6+
7+ SECTIONS {
8+ . foo : { * (. text. foo) } > RAM
9+ . empty : {} > RAM
10+ tdata : { * (. tdata* ) } > ROM
11+ tbss : { * (. tbss* ) } > ROM
12+ . empty : {} > ROM
13+ . main : { * (. text. main) } > ROM
14+ output_data : { BYTE(0x0 ) * (. data* ) } > ROM
15+ /DISCARD / : { * (. riscv. attributes ) }
16+ }
Original file line number Diff line number Diff line change 1+ __thread int b = 0 ;
2+ int data = 100 ;
3+ int foo () { return 0 ; }
4+ int main () { return 0 ; }
Original file line number Diff line number Diff line change 1+ UNSUPPORTED: ndk-build
2+ #---OnlyTBSS.test--------------------------- Executable -----------------#
3+ #BEGIN_COMMENT
4+ # This tests that using TBSS only does not create an empty segment
5+ #END_COMMENT
6+ #START_TEST
7+ RUN: %clang %clangopts -c %p/Inputs/tls.c -o %t1.1.o -fdata-sections -ftls-model=local-exec -fPIE
8+ RUN: %link %linkopts %t1.1.o -T %p/Inputs/script.t -o %t.out --defsym __aeabi_read_tp=0
9+ RUN: %readelf -l -W %t.out | %filecheck %s -check-prefix=EMPTYLOAD
10+ RUN: %link %linkopts %t1.1.o -T %p/Inputs/scripttbssnewregion.t -o %t.out --defsym __aeabi_read_tp=0
11+ RUN: %readelf -l -W %t.out | %filecheck %s -check-prefix=EMPTYLOAD
12+ #END_TEST
13+
14+ #EMPTYLOAD-NOT: LOAD {{.*}} {{.*}} {{.*}} 0x{{[0]+}} 0x{{[0]+}} {{.*}}
You can’t perform that action at this time.
0 commit comments