james@bigtex.cactus.org (James Van Artsdalen) (01/06/91)
I believe I have resolved most of the bugs involving compiling Thomas
Roell's X11r4 server and gcc 1.38.
The first patch fixes a bug in gcc wherein static uninitialized local
variables are put in .bss instead of .data. The difference is moot
unless you're trying to build a shared library.
The next set of patches fix some indirect calls through uninitialized
variables in the X libraries. There might be more of these: they are
hard to find via regular expression searches.
The last patch is to a bug in the X server - a define is wrong. I
don't know what damage it was doing.
I would like to know of any core dumps that remain. I am especially
interested in any bugs involving the 387 that anyone can induce.
*** /tmp/,RCSt1a14640 Sat Jan 5 18:05:49 1991
--- config/tm-att386.h Fri Jan 4 23:49:05 1991
***************
*** 145,166 ****
#define DATA_SECTION_ASM_OP ".data"
- /* Output before uninitialized data. */
-
- #define BSS_SECTION_ASM_OP ".bss"
-
- #define EXTRA_SECTIONS in_bss
-
- #define EXTRA_SECTION_FUNCTIONS \
- void \
- bss_section () \
- { \
- if (in_section != in_bss) \
- { \
- fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP); \
- in_section = in_bss; \
- } \
- }
/* Define the syntax of labels and symbol definitions/declarations. */
--- 145,150 ----
***************
*** 179,185 ****
to define a local common symbol. */
#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
! (bss_section (), \
ASM_OUTPUT_LABEL ((FILE), (NAME)), \
fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED)))
--- 163,169 ----
to define a local common symbol. */
#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
! (data_section (), \
ASM_OUTPUT_LABEL ((FILE), (NAME)), \
fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED)))
===========================================================================
/usr/local/src/X/mit> rcsdiff -c lib/X/XGetDflt.c lib/Xaw/Clock.c lib/Xaw/Mailbox.c server/ddx/mi/mispritest.h
RCS file: lib/X/RCS/XGetDflt.c,v
retrieving revision 1.1
diff -c -r1.1 lib/X/XGetDflt.c
*** /tmp/,RCSt1a14655 Sat Jan 5 18:08:00 1991
--- lib/X/XGetDflt.c Sat Jan 5 16:12:00 1991
***************
*** 33,45 ****
#include "Xlibint.h"
#include <X11/Xresource.h>
static char *GetHomeDir (dest)
char *dest;
{
int uid;
extern char *getenv();
- extern int getuid();
- extern struct passwd *getpwuid(), *getpwnam();
struct passwd *pw;
register char *ptr;
--- 33,46 ----
#include "Xlibint.h"
#include <X11/Xresource.h>
+ extern int getuid();
+ extern struct passwd *getpwuid(), *getpwnam();
+
static char *GetHomeDir (dest)
char *dest;
{
int uid;
extern char *getenv();
struct passwd *pw;
register char *ptr;
===================================================================
RCS file: lib/Xaw/RCS/Clock.c,v
retrieving revision 1.1
diff -c -r1.1 lib/Xaw/Clock.c
*** /tmp/,RCSt1a14655 Sat Jan 5 18:08:00 1991
--- lib/Xaw/Clock.c Sat Jan 5 17:32:30 1991
***************
*** 170,175 ****
--- 170,177 ----
NULL, 0 );
}
+ extern struct tm *localtime();
+
/* ARGSUSED */
STATIC void Initialize (request, new)
Widget request, new;
***************
*** 189,195 ****
if(!w->clock.analog) {
char *str;
struct tm tm;
- extern struct tm *localtime();
long time_value;
(void) time(&time_value);
tm = *localtime(&time_value);
--- 191,196 ----
***************
*** 313,319 ****
XtIntervalId *id;
{
ClockWidget w = (ClockWidget)client_data;
- struct tm *localtime();
struct tm tm;
long time_value;
char *time_ptr;
--- 314,319 ----
***************
*** 512,517 ****
--- 512,520 ----
}
}
+ extern double cos();
+ extern double sin();
+
/*
* DrawLine - Draws a line.
*
***************
*** 533,540 ****
{
double dblank_length = (double)blank_length, dlength = (double)length;
double angle, cosangle, sinangle;
- extern double cos();
- extern double sin();
int cx = w->clock.centerX, cy = w->clock.centerY, x1, y1, x2, y2;
/*
--- 536,541 ----
***************
*** 576,583 ****
register double angle, cosangle, sinangle;
register double ws, wc;
Position x, y, x1, y1, x2, y2;
- extern double cos();
- extern double sin();
/*
* A full circle is 2 PI radians.
--- 577,582 ----
***************
*** 635,642 ****
register double ms, mc, ws, wc;
register int mid;
Position x, y;
- extern double cos();
- extern double sin();
/*
* A full circle is 2 PI radians.
--- 634,639 ----
===================================================================
*** /tmp/,RCSt1a14655 Sat Jan 5 18:08:01 1991
--- lib/Xaw/Mailbox.c Sat Jan 5 16:17:02 1991
***************
*** 510,524 ****
* get user name for building mailbox
*/
static void GetMailFile (w)
MailboxWidget w;
{
- extern char *getlogin();
char *username;
username = getlogin ();
if (!username) {
- extern struct passwd * getpwuid();
struct passwd *pw = getpwuid (getuid ());
if (!pw) {
--- 510,525 ----
* get user name for building mailbox
*/
+ extern char *getlogin();
+ extern struct passwd * getpwuid();
+
static void GetMailFile (w)
MailboxWidget w;
{
char *username;
username = getlogin ();
if (!username) {
struct passwd *pw = getpwuid (getuid ());
if (!pw) {
===================================================================
RCS file: server/ddx/mi/RCS/mispritest.h,v
retrieving revision 1.1
diff -c -r1.1 server/ddx/mi/mispritest.h
*** /tmp/,RCSt1a14655 Sat Jan 5 18:08:01 1991
--- server/ddx/mi/mispritest.h Fri Dec 21 10:12:24 1990
***************
*** 92,98 ****
*/
#define SPN_OVERLAP(pCbox,y,x,w) BOX_OVERLAP((pCbox),(x),(y),(x)+(w),(y))
! #define LINE_SORT(x1,y2,x2,y2) \
{ int _t; \
if (x1 > x2) { _t = x1; x1 = x2; x2 = _t; } \
if (y1 > y2) { _t = y1; y1 = y2; y2 = _t; } }
--- 92,98 ----
*/
#define SPN_OVERLAP(pCbox,y,x,w) BOX_OVERLAP((pCbox),(x),(y),(x)+(w),(y))
! #define LINE_SORT(x1,y1,x2,y2) \
{ int _t; \
if (x1 > x2) { _t = x1; x1 = x2; x2 = _t; } \
if (y1 > y2) { _t = y1; y1 = y2; y2 = _t; } }
--
James R. Van Artsdalen james@bigtex.cactus.org "Live Free or Die"
Dell Computer Co 9505 Arboretum Blvd Austin TX 78759 512-338-8789roell@informatik.tu-muenchen.dbp.de (Thomas Roell) (01/07/91)
>The first patch fixes a bug in gcc wherein static uninitialized local >variables are put in .bss instead of .data. The difference is moot >unless you're trying to build a shared library. Hmm... I got also to this problem soon after gcc 1.38 was released. But I found some different solutions: a) Adding a flag to gcc (-mnobss) so that gcc generates no code for the .bss segment. Is is not good, cause it's only a partial fix, and may no apply to other c-compilers. b) Letting ld(1) change the .bss contents into initialized date. This looks like this: ld -rx ifile file.o -o shared/file.o with ifile: SECTIONS { .text : { *(.text) } .data : { *(.data .bss) } .bss : {} } But for a reason I don't know the mkshlib(1) utility the fails when creating lib???_s.a with the message: cannot take OVERLAY section as input (or something like this) I assume this is a bug in ld(1). c) Adding explecitely a section .bss to the shared lib. This fails with a coredump, when trying to execute a client. This may also be caused by uninitialized pointers mentioned below. Besides this would take to much run-time space... d) (My favourite) Writing an utility that takes a coff-files as input that adds the .bss section to the .data section (like b)). I'm working on this, cause this would be the general solution. >The next set of patches fix some indirect calls through uninitialized >variables in the X libraries. There might be more of these: they are >hard to find via regular expression searches. I cannot believe this. Because I'm working on the problem above I had no time to look at this problem. But let me here say what really *should* happen: o In import.h there is an indirection define, which redirects every call to functions that can not be referd as absolute to a pointer. o Also in import.h the are some declarations like: extern int uname(); This is neccessary, cause a common c-praxis is to omit the exern declation of of funtion that returns int, or is type-casted when called. The bad thing is that this fails, if we redirected the function-call via a pointer. Thus we make here some explicitely declarations. o Any further REDECLARTION in the main c-file (that's what is mentioned in the original article) should have NO effect, except that there might be warnings. The c-compiler should generate either a unresolved reference to this pointer, or a reference to a common symbol. Both cases lead to the same effect, the pointer is referenced as the one that's really in globals.c. o Any further REDECLARTION WITHOUT extern will be a problem, cause then a local symbol is generated. That will be the reason for jumps over non- initialized pointers. My question is now, does gcc 1-38 anything other ???? - Thomas -- _______________________________________________________________________________ E-Mail (domain): roell@lan.informatik.tu-muenchen.de UUCP (when above fails): roell@tumult.{uucp | informatik.tu-muenchen.de} famous last words: "diskspace - the final frontier..."