jonathan@comp.vuw.ac.nz (11/13/89)
Description:
The gnu loader, as distributed with g++ 1.36.1, does not
properly relocate references to external symbols in
NMAGIC .o files. This loses on Pyramids.
Repeat-by:
Compile the following files as NMAGIC. as(1) on Pyramid OSx
does this by default. On other systems compile, move the .o
files elsewhere, and do `ld -r -n' on each .o file.
(I verified the bug on Mt.Xinu's 4.3bsd-tahoe for HP300s. Any
4.3bsd-based system should do.)
Load the resulting .o files with gnu ld and run the program.
It should print the same values for buggy and buggy_p.
Instead, buggy_p is erroneously zero.
Making the .o files OMAGIC (via `ld -r -N') and loading again
gives correct results.
---main.c---
/* main () of program to demonstrate bug in GNU ld on pyramids */
#include <stdio.h>
#include "buggy.h"
char *buggy_p = buggy;
main ()
{
char * auto_buggy_p = buggy;
printf("&buggy=%x buggy_p=%x auto_buggy_p=%x\n",
buggy, buggy_p, auto_buggy_p);
}
---buggy.c:---
/* demonstrate bug in GNU ld on pyramids */
#include "buggy.h"
char buggy[1024];
---buggy.h:---
extern char buggy[];
-------------
Fix-by:
???
Workaround:
Performing ld -r -N either manually or in the GNU CC driver
works, albeit painfully.