When initialized data is found in a segment, print the first module where this

data comes from to ease debugging.
This commit is contained in:
Kugel Fuhr
2025-07-10 21:23:41 +02:00
parent 2e3edf9b1b
commit c2f17b6f6b
3 changed files with 29 additions and 13 deletions

View File

@@ -1709,10 +1709,20 @@ static void ProcessSegments (void)
** in any of the object file, check that there's no initialized data
** in the segment.
*/
if ((S->Flags & SF_BSS) != 0 && S->Seg != 0 && !IsBSSType (S->Seg)) {
PWarning (GetSourcePos (S->LI),
"Segment `%s' with type `bss' contains initialized data",
GetString (S->Name));
if ((S->Flags & SF_BSS) != 0 && S->Seg != 0) {
Section* Sec = GetNonBSSSection (S->Seg);
if (Sec) {
const FilePos* Pos = GetSourcePos (S->LI);
if (Sec->Obj) {
AddPNote (Pos, "Initialized data comes at least partially "
"from `%s'", GetString (Sec->Obj->Name));
} else {
AddPNote (Pos, "Initialized data is at least partially "
"linker generated");
}
PWarning (Pos, "Segment `%s' with type `bss' contains "
"initialized data", GetString (S->Name));
}
}
/* If this segment does exist in any of the object files, insert the