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:
@@ -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
|
||||
|
||||
@@ -306,9 +306,11 @@ Segment* SegFind (unsigned Name)
|
||||
|
||||
|
||||
|
||||
int IsBSSType (Segment* S)
|
||||
/* Check if the given segment is a BSS style segment, that is, it does not
|
||||
** contain non-zero data.
|
||||
Section* GetNonBSSSection (Segment* S)
|
||||
/* Used when checking a BSS style segment for initialized data. Will walk over
|
||||
** all sections in S and check if any of them contains initialized data. If so,
|
||||
** the first section containing initialized data is returned. Otherwise the
|
||||
** function returns NULL.
|
||||
*/
|
||||
{
|
||||
/* Loop over all sections */
|
||||
@@ -326,18 +328,20 @@ int IsBSSType (Segment* S)
|
||||
unsigned long Count = F->Size;
|
||||
while (Count--) {
|
||||
if (*Data++ != 0) {
|
||||
return 0;
|
||||
return Sec;
|
||||
}
|
||||
}
|
||||
} else if (F->Type == FRAG_EXPR || F->Type == FRAG_SEXPR) {
|
||||
if (GetExprVal (F->Expr) != 0) {
|
||||
return 0;
|
||||
return Sec;
|
||||
}
|
||||
}
|
||||
F = F->Next;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
/* No uninitialized data found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -131,9 +131,11 @@ Section* ReadSection (FILE* F, struct ObjData* O);
|
||||
Segment* SegFind (unsigned Name);
|
||||
/* Return the given segment or NULL if not found. */
|
||||
|
||||
int IsBSSType (Segment* S);
|
||||
/* Check if the given segment is a BSS style segment, that is, it does not
|
||||
** contain non-zero data.
|
||||
Section* GetNonBSSSection (Segment* S);
|
||||
/* Used when checking a BSS style segment for initialized data. Will walk over
|
||||
** all sections in S and check if any of them contains initialized data. If so,
|
||||
** the first section containing initialized data is returned. Otherwise the
|
||||
** function returns NULL.
|
||||
*/
|
||||
|
||||
void SegDump (void);
|
||||
|
||||
Reference in New Issue
Block a user