qualcomm / qualcomm/eld

Incorrect size of `.tbss_space` if `.tbss` has an explicit output section address and memory region

Open
#367 0 comments 0 reactions 1 assignee View on GitHub

@partaror is already working on this.

Since Mar 31, 2026.

bug
Dominant language
C++
Stars
259
Forks
84
Avg merge
2d 14h
Merged PRs (30d)
72

Description

.tbss_space has incorrect size when .tbss output section has an explicit address and memory region.

Reproducer:

#!/usr/bin/env bash

cat > script.t << '!'
MEMORY {
  RAM : ORIGIN = 0x1000, LENGTH = 0x3000
}

SECTIONS {
  .text : { *(.text*) *(*text*) } >RAM
  .tdata : { *(.tdata*) } >RAM
  .tbss (0x2014) (NOLOAD) : {
    *(.tbss*)
  } >RAM
  .tbss_space (NOLOAD) :{
    . = ADDR(.tbss);
    . = . + SIZEOF(.tbss);
  } >RAM
}
!

cat > 1.c << '!'
_Thread_local int u;

_Thread_local int v = 1;

int foo() { return u; }

int bar() { return v; }
!

LDs=(ld.eld)
SFs=(eld)

clang -o 1.o --target=riscv64-unknown-elf -c 1.c -ffunction-sections -fdata-sections

for i in "${!SFs[@]}"; do
  ${LDs[$i]} -o 1.${SFs[$i]}.out 1.o -T script.t -Map 1.${SFs[$i]}.map.txt 
done
llvm-readelf -S 1.eld.out | grep .tbss_space
#  [ 4] .tbss_space       NOBITS          000000000000103c 00103c 000fdc 00  WA  0   0  1
#
# Expected size is 4.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.