From owner-freebsd-hackers Sun Aug 1 23: 8: 5 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from joelu.m8.ntu.edu.tw (JoeLu.m8.ntu.edu.tw [140.112.253.138]) by hub.freebsd.org (Postfix) with SMTP id 0920714BF9 for ; Sun, 1 Aug 1999 23:07:48 -0700 (PDT) (envelope-from JoeLu@joelu.m8.ntu.edu.tw) Received: (qmail 18640 invoked by uid 1000); 2 Aug 1999 06:14:25 -0000 To: freebsd-hackers@FreeBSD.org Subject: How the `struct linker_set' is used in building an ELF kernel? Reply-To: b84118@ee.ntu.edu.tw From: Joe Jih-Shien Lu Date: 02 Aug 1999 14:14:24 +0800 Message-ID: <87n1wag14v.fsf@JoeLu.m8.ntu.edu.tw> Lines: 34 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi everybody, I started studying 3.2-stable kernel source for days. There are some questions I cannot figure out in an ordinary C programmer's point of view: * In cninit(), it references a global variable `cons_set' of the type `struct linker_set,' but I don't see its definition in any of the source files except the setdef0.c generated by /usr/bin/gensetdefs. It is defined by the .long asm psuedo-op, and seems to have the size of 4 bytes. However, in /sys/i386/i386/cons.h, it is declared as of the type `struct linker_set' which is 8-byte long. This inconsistency confused me. * Similar problem is encountered when I'm poking around the system initializing for-loop in main(). sysinit_set, declared as struct linker_set, is referenced, but I can't get into the way how this variable is initialized. I guess it is the linker who did all the magic, since the comment in /sys/sys/linker_set.h mentioned about it. After studying the linker script (/sys/i386/conf/kernel.script) and ld.info, though, I still don't have any idea about the details behind the scene. I notice that gensetdefs looks for the sections by the `.set.'-prefixed name in all the ELF kernel object files, and produces the setdef[12].c accordingly. Does the `.set.'-prefixed section name have any special meaning in an ELF object file? I hope someone can give me a hint, thanks. -- Joe Jih-Shien Lu [¿c¬ö¾Ë] mailto:b84118@ee.ntu.edu.tw ---------------------------------------------------------------------- The trouble with being poor is that it takes up all your time. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message