- if ((S->Flags & SF_TRAMPOLINE) == 0 &&
- (S->Flags & SF_UNDEFMASK) != SF_UNDEFVAL) {
- if ((S->Flags & SF_DEFINED) != 0 && (S->Flags & SF_REFERENCED) == 0) {
- /* Symbol was defined but never referenced */
- PWarning (&S->Pos, 2,
- "Symbol `%s' is defined but never used",
- GetString (S->Name));
- }
- if (S->Flags & SF_IMPORT) {
- if ((S->Flags & (SF_REFERENCED | SF_FORCED)) == SF_NONE) {
- /* Imported symbol is not referenced */
- PWarning (&S->Pos, 2,
- "Symbol `%s' is imported but never used",
- GetString (S->Name));
- } else {
- /* Give the import an index, count imports */
- S->Index = ImportCount++;
- S->Flags |= SF_INDEXED;
- }
- }
- if (S->Flags & SF_EXPORT) {
- /* Give the export an index, count exports */
- S->Index = ExportCount++;
- S->Flags |= SF_INDEXED;
- }
- }
-
- /* Next symbol */
- S = S->List;
+ if ((S->Flags & SF_UNUSED) == 0 &&
+ (S->Flags & SF_UNDEFMASK) != SF_UNDEFVAL) {
+
+ /* Check for defined symbols that were never referenced */
+ if (IsSizeOfSymbol (S)) {
+ /* Remove line infos, we don't need them any longer */
+ ReleaseFullLineInfo (&S->DefLines);
+ ReleaseFullLineInfo (&S->RefLines);
+ } else if ((S->Flags & SF_DEFINED) != 0 && (S->Flags & SF_REFERENCED) == 0) {
+ LIWarning (&S->DefLines, 2,
+ "Symbol `%m%p' is defined but never used",
+ GetSymName (S));
+ }
+
+ /* Assign an index to all imports */
+ if (S->Flags & SF_IMPORT) {
+ if ((S->Flags & (SF_REFERENCED | SF_FORCED)) == SF_NONE) {
+ /* Imported symbol is not referenced */
+ LIWarning (&S->DefLines, 2,
+ "Symbol `%m%p' is imported but never used",
+ GetSymName (S));
+ } else {
+ /* Give the import an id, count imports */
+ S->ImportId = ImportCount++;
+ }
+ }
+
+ /* Count exports, assign the export ID */
+ if (S->Flags & SF_EXPORT) {
+ S->ExportId = ExportCount++;
+ }
+
+ /* If the symbol is defined but has an unknown address size,
+ ** recalculate it.
+ */
+ if (SymHasExpr (S) && S->AddrSize == ADDR_SIZE_DEFAULT) {
+ ExprDesc ED;
+ ED_Init (&ED);
+ StudyExpr (S->Expr, &ED);
+ S->AddrSize = ED.AddrSize;
+ if (SymIsExport (S)) {
+ if (S->ExportSize == ADDR_SIZE_DEFAULT) {
+ /* Use the real export size */
+ S->ExportSize = S->AddrSize;
+ } else if (S->AddrSize > S->ExportSize) {
+ /* We're exporting a symbol smaller than it actually is */
+ LIWarning (&S->DefLines, 1,
+ "Symbol `%m%p' is %s but exported %s",
+ GetSymName (S),
+ AddrSizeToStr (S->AddrSize),
+ AddrSizeToStr (S->ExportSize));
+ }
+ }
+ ED_Done (&ED);
+ }
+
+ /* If the address size of the symbol was guessed, check the guess
+ ** against the actual address size and print a warning if the two
+ ** differ.
+ */
+ if (S->AddrSize != ADDR_SIZE_DEFAULT) {
+ /* Do we have data for this address size? */
+ if (S->AddrSize <= sizeof (S->GuessedUse) / sizeof (S->GuessedUse[0])) {
+ /* Get the file position where the symbol was used */
+ const FilePos* P = S->GuessedUse[S->AddrSize - 1];
+ if (P) {
+ PWarning (P, 0,
+ "Didn't use %s addressing for `%m%p'",
+ AddrSizeToStr (S->AddrSize),
+ GetSymName (S));
+ }
+ }
+ }
+
+ }
+
+ /* Next symbol */
+ S = S->List;