Bug 19882

Summary: ld does not detect all undefined symbols!
Product: Base System Reporter: peter <peter>
Component: gnuAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: emaste
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   

Description peter 2000-07-13 04:10:01 UTC
	Certain gas-generated external references to undefined symbols
	are not noticed by ld.  For example:

	andl    $~AST_RESCHED,_astpending

	If AST_RESCHED is undefined (remove the #include <machine/ipl.h>
	in i386/i386/swtch.s to cause this), then the kernel ends up with:

	$ nm kernel | grep AST_
		 U AST_RESCHED

Fix: 

Unknown.
How-To-Repeat: 
	Remove #include <machine/ipl.h> from i386/i386/swtch.s, build a
	kernel.  It will compile and end up with an undefined symbol.
	This was an actual problem in RELENG_4 from May 16th through
	July 12th.  ld(8) did not mention it.  The new binutils has
	a --no-undefined flag, but even that does not detect the undefined
	symbol.
Comment 1 Peter Wemm freebsd_committer freebsd_triage 2000-07-13 04:23:16 UTC
Responsible Changed
From-To: freebsd-bugs->obrien

Bintuils related
Comment 2 alex.neyman 2003-06-20 07:15:13 UTC
[I've CC'ed kan@ as he's also working on GCC/binutils]

I just tried to reproduce it. As the suggested how-to-repeat procedure
is no longer available, I tried to #undef out PAGE_MASK in i386/locore.s.
While the kernel failed to build, the error message is somewhat
confusing:

linking kernel.debug
ld: locore.o: bad symbol index: 1190440
locore.o: could not read symbols: File format not recognized
*** Error code 1

bash-2.05b$ nm /usr/obj/usr/src/sys/V2/locore.o | grep PAGE_MASK
         U PAGE_MASK
bash-2.05b$

Without this #undef, the kernel builds just fine:

linking kernel.debug
   text    data     bss     dec     hex filename
2863749  310081  422996 3596826  36e21a kernel.debug
objcopy --strip-debug kernel.debug kernel

Could the behavior described by the originator happen if the [seemingly]
junk in symbol index in locore.s has some more meaningful value?

Regards,
Alexey.
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:58:52 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 4 Ed Maste freebsd_committer freebsd_triage 2018-04-13 01:46:52 UTC
Issue overcome by our switch to lld as FreeBSD's system linker.