Date: Thu, 17 Sep 1998 21:33:16 +0200 (CEST) From: Joachim Kuebart <joki@kuebart.stuttgart.netsurf.de> To: freebsd-current@FreeBSD.ORG (FreeBSD Current) Subject: Correct names for C globals in kernel Message-ID: <199809171933.VAA29946@yacht.domestic.de>
next in thread | raw e-mail | index | archive | help
Hi,
this patch is interesting if it is planned to convert the kernel
itself to ELF. With these patches, the kernel will link in an ELF
world.
Under /usr/src/sys there is an assembler macro called CNAME that
adds an optional underscore to global symbols when needed. However,
that macro is rarely used. The following patch remedies that:
Index: i386/i386/exception.s
===================================================================
RCS file: /usr/CVS-Repository/src/sys/i386/i386/exception.s,v
retrieving revision 1.55
diff -u -r1.55 exception.s
--- exception.s 1998/08/10 19:41:07 1.55
+++ exception.s 1998/09/01 00:22:25
@@ -312,7 +312,7 @@
ENTRY(fork_trampoline)
call _spl0
- movl _curproc,%eax
+ movl CNAME(curproc),%eax
addl $P_SWITCHTIME,%eax
movl _switchtime,%ecx
testl %ecx,%ecx
Index: i386/i386/globals.s
===================================================================
RCS file: /usr/CVS-Repository/src/sys/i386/i386/globals.s,v
retrieving revision 1.7
diff -u -r1.7 globals.s
--- globals.s 1998/08/18 07:46:58 1.7
+++ globals.s 1998/09/01 00:22:25
@@ -59,7 +59,7 @@
.set _prv_CPAGE3,_SMP_prvstart + PS_CPAGE3
.set _prv_PPAGE1,_SMP_prvstart + PS_PPAGE1
.set _SMP_ioapic,_SMP_prvstart + PS_IOAPICS
-#endif
+#endif /* SMP */
/*
* Define layout of the global data. On SMP this lives in
@@ -70,20 +70,21 @@
ALIGN_DATA
globaldata:
.space GD_SIZEOF /* in data segment */
-#endif
- .globl _curproc,_curpcb,_npxproc,_common_tss,_switchtime
- .set _curproc,globaldata + GD_CURPROC
- .set _curpcb,globaldata + GD_CURPCB
- .set _npxproc,globaldata + GD_NPXPROC
- .set _common_tss,globaldata + GD_COMMON_TSS
- .set _switchtime,globaldata + GD_SWITCHTIME
+#endif /* !SMP */
+ .globl CNAME(curproc),CNAME(curpcb),CNAME(npxproc)
+ .globl CNAME(common_tss),CNAME(switchtime)
+ .set CNAME(curproc),globaldata + GD_CURPROC
+ .set CNAME(curpcb),globaldata + GD_CURPCB
+ .set CNAME(npxproc),globaldata + GD_NPXPROC
+ .set CNAME(common_tss),globaldata + GD_COMMON_TSS
+ .set CNAME(switchtime),globaldata + GD_SWITCHTIME
#ifdef VM86
- .globl _common_tssd,_private_tss,_my_tr
- .set _common_tssd,globaldata + GD_COMMON_TSSD
- .set _private_tss,globaldata + GD_PRIVATE_TSS
- .set _my_tr,globaldata + GD_MY_TR
-#endif
+ .globl CNAME(common_tssd),CNAME(private_tss),CNAME(my_tr)
+ .set CNAME(common_tssd),globaldata + GD_COMMON_TSSD
+ .set CNAME(private_tss),globaldata + GD_PRIVATE_TSS
+ .set CNAME(my_tr),globaldata + GD_MY_TR
+#endif /* VM86 */
#ifdef USER_LDT
.globl _currentldt
@@ -109,7 +110,7 @@
.set _prv_CMAP3,globaldata + GD_PRV_CMAP3
.set _prv_PMAP1,globaldata + GD_PRV_PMAP1
.set _inside_intr,globaldata + GD_INSIDE_INTR
-#endif
+#endif /* SMP */
#if defined(SMP) || defined(APIC_IO)
.globl lapic_eoi, lapic_svr, lapic_tpr, lapic_irr1, lapic_ver
@@ -176,4 +177,4 @@
.set lapic_ticr, _lapic + 0x380
.set lapic_tccr, _lapic + 0x390
.set lapic_tdcr, _lapic + 0x3e0
-#endif
+#endif /* SMP || APIC_IO */
Index: i386/i386/locore.s
===================================================================
RCS file: /usr/CVS-Repository/src/sys/i386/i386/locore.s,v
retrieving revision 1.112
diff -u -r1.112 locore.s
--- locore.s 1998/08/03 21:31:32 1.112
+++ locore.s 1998/09/01 00:22:25
@@ -369,7 +369,7 @@
movl _proc0paddr,%eax
movl _IdlePTD, %esi
movl %esi,PCB_CR3(%eax)
- movl $_proc0,_curproc
+ movl $_proc0,CNAME(curproc)
movl physfree, %esi
pushl %esi /* value of first for init386(first) */
Index: i386/i386/support.s
===================================================================
RCS file: /usr/CVS-Repository/src/sys/i386/i386/support.s,v
retrieving revision 1.59
diff -u -r1.59 support.s
--- support.s 1998/05/11 02:13:43 1.59
+++ support.s 1998/06/21 14:37:05
@@ -243,7 +243,7 @@
* method. CR0_TS must be preserved although it is very likely to
* always end up as clear.
*/
- cmpl $0,_npxproc
+ cmpl $0,CNAME(npxproc)
je i586_bz1
cmpl $256+184,%ecx /* empirical; not quite 2*108 more */
jb intreg_i586_bzero
@@ -295,7 +295,7 @@
cmpl $8,%ecx
jae fpureg_i586_bzero_loop
- cmpl $0,_npxproc
+ cmpl $0,CNAME(npxproc)
je i586_bz3
frstor 0(%esp)
addl $108,%esp
@@ -504,7 +504,7 @@
sarb $1,kernel_fpu_lock
jc small_i586_bcopy
- cmpl $0,_npxproc
+ cmpl $0,CNAME(npxproc)
je i586_bc1
smsw %dx
clts
@@ -575,7 +575,7 @@
cmpl $64,%ecx
jae 4b
- cmpl $0,_npxproc
+ cmpl $0,CNAME(npxproc)
je i586_bc2
frstor 0(%esp)
addl $108,%esp
@@ -671,7 +671,7 @@
jmp *_copyout_vector
ENTRY(generic_copyout)
- movl _curpcb,%eax
+ movl CNAME(curpcb),%eax
movl $copyout_fault,PCB_ONFAULT(%eax)
pushl %esi
pushl %edi
@@ -782,7 +782,7 @@
popl %edi
popl %esi
xorl %eax,%eax
- movl _curpcb,%edx
+ movl CNAME(curpcb),%edx
movl %eax,PCB_ONFAULT(%edx)
ret
@@ -791,7 +791,7 @@
popl %ebx
popl %edi
popl %esi
- movl _curpcb,%edx
+ movl CNAME(curpcb),%edx
movl $0,PCB_ONFAULT(%edx)
movl $EFAULT,%eax
ret
@@ -801,7 +801,7 @@
/*
* Duplicated from generic_copyout. Could be done a bit better.
*/
- movl _curpcb,%eax
+ movl CNAME(curpcb),%eax
movl $copyout_fault,PCB_ONFAULT(%eax)
pushl %esi
pushl %edi
@@ -856,7 +856,7 @@
jmp *_copyin_vector
ENTRY(generic_copyin)
- movl _curpcb,%eax
+ movl CNAME(curpcb),%eax
movl $copyin_fault,PCB_ONFAULT(%eax)
pushl %esi
pushl %edi
@@ -894,7 +894,7 @@
popl %edi
popl %esi
xorl %eax,%eax
- movl _curpcb,%edx
+ movl CNAME(curpcb),%edx
movl %eax,PCB_ONFAULT(%edx)
ret
@@ -902,7 +902,7 @@
copyin_fault:
popl %edi
popl %esi
- movl _curpcb,%edx
+ movl CNAME(curpcb),%edx
movl $0,PCB_ONFAULT(%edx)
movl $EFAULT,%eax
ret
@@ -912,7 +912,7 @@
/*
* Duplicated from generic_copyin. Could be done a bit better.
*/
- movl _curpcb,%eax
+ movl CNAME(curpcb),%eax
movl $copyin_fault,PCB_ONFAULT(%eax)
pushl %esi
pushl %edi
@@ -966,13 +966,13 @@
jnz fastmove_tail
/* if (npxproc != NULL) { */
- cmpl $0,_npxproc
+ cmpl $0,CNAME(npxproc)
je 6f
/* fnsave(&curpcb->pcb_savefpu); */
- movl _curpcb,%eax
+ movl CNAME(curpcb),%eax
fnsave PCB_SAVEFPU(%eax)
/* npxproc = NULL; */
- movl $0,_npxproc
+ movl $0,CNAME(npxproc)
/* } */
6:
/* now we own the FPU. */
@@ -989,7 +989,7 @@
movl %esi,-8(%ebp)
movl %edi,-4(%ebp)
movl %esp,%edi
- movl _curpcb,%esi
+ movl CNAME(curpcb),%esi
addl $PCB_SAVEFPU,%esi
cld
movl $PCB_SAVEFPU_SIZE>>2,%ecx
@@ -1001,9 +1001,9 @@
/* stop_emulating(); */
clts
/* npxproc = curproc; */
- movl _curproc,%eax
- movl %eax,_npxproc
- movl _curpcb,%eax
+ movl CNAME(curproc),%eax
+ movl %eax,CNAME(npxproc)
+ movl CNAME(curpcb),%eax
movl $fastmove_fault,PCB_ONFAULT(%eax)
4:
movl %ecx,-12(%ebp)
@@ -1065,7 +1065,7 @@
movl %ecx,-12(%ebp)
movl %esi,-8(%ebp)
movl %edi,-4(%ebp)
- movl _curpcb,%edi
+ movl CNAME(curpcb),%edi
addl $PCB_SAVEFPU,%edi
movl %esp,%esi
cld
@@ -1081,11 +1081,11 @@
orb $CR0_TS,%al
lmsw %ax
/* npxproc = NULL; */
- movl $0,_npxproc
+ movl $0,CNAME(npxproc)
ALIGN_TEXT
fastmove_tail:
- movl _curpcb,%eax
+ movl CNAME(curpcb),%eax
movl $fastmove_tail_fault,PCB_ONFAULT(%eax)
movb %cl,%al
@@ -1104,7 +1104,7 @@
ALIGN_TEXT
fastmove_fault:
- movl _curpcb,%edi
+ movl CNAME(curpcb),%edi
addl $PCB_SAVEFPU,%edi
movl %esp,%esi
cld
@@ -1115,7 +1115,7 @@
smsw %ax
orb $CR0_TS,%al
lmsw %ax
- movl $0,_npxproc
+ movl $0,CNAME(npxproc)
fastmove_tail_fault:
movl %ebp,%esp
@@ -1124,7 +1124,7 @@
popl %ebx
popl %edi
popl %esi
- movl _curpcb,%edx
+ movl CNAME(curpcb),%edx
movl $0,PCB_ONFAULT(%edx)
movl $EFAULT,%eax
ret
@@ -1134,7 +1134,7 @@
* fu{byte,sword,word} : fetch a byte (sword, word) from user memory
*/
ENTRY(fuword)
- movl _curpcb,%ecx
+ movl CNAME(curpcb),%ecx
movl $fusufault,PCB_ONFAULT(%ecx)
movl 4(%esp),%edx /* from */
@@ -1157,7 +1157,7 @@
ret
ENTRY(fusword)
- movl _curpcb,%ecx
+ movl CNAME(curpcb),%ecx
movl $fusufault,PCB_ONFAULT(%ecx)
movl 4(%esp),%edx
@@ -1169,7 +1169,7 @@
ret
ENTRY(fubyte)
- movl _curpcb,%ecx
+ movl CNAME(curpcb),%ecx
movl $fusufault,PCB_ONFAULT(%ecx)
movl 4(%esp),%edx
@@ -1182,7 +1182,7 @@
ALIGN_TEXT
fusufault:
- movl _curpcb,%ecx
+ movl CNAME(curpcb),%ecx
xorl %eax,%eax
movl %eax,PCB_ONFAULT(%ecx)
decl %eax
@@ -1192,7 +1192,7 @@
* su{byte,sword,word}: write a byte (word, longword) to user memory
*/
ENTRY(suword)
- movl _curpcb,%ecx
+ movl CNAME(curpcb),%ecx
movl $fusufault,PCB_ONFAULT(%ecx)
movl 4(%esp),%edx
@@ -1236,12 +1236,12 @@
movl 8(%esp),%eax
movl %eax,(%edx)
xorl %eax,%eax
- movl _curpcb,%ecx
+ movl CNAME(curpcb),%ecx
movl %eax,PCB_ONFAULT(%ecx)
ret
ENTRY(susword)
- movl _curpcb,%ecx
+ movl CNAME(curpcb),%ecx
movl $fusufault,PCB_ONFAULT(%ecx)
movl 4(%esp),%edx
@@ -1285,13 +1285,13 @@
movw 8(%esp),%ax
movw %ax,(%edx)
xorl %eax,%eax
- movl _curpcb,%ecx /* restore trashed register */
+ movl CNAME(curpcb),%ecx /* restore trashed register */
movl %eax,PCB_ONFAULT(%ecx)
ret
ALTENTRY(suibyte)
ENTRY(subyte)
- movl _curpcb,%ecx
+ movl CNAME(curpcb),%ecx
movl $fusufault,PCB_ONFAULT(%ecx)
movl 4(%esp),%edx
@@ -1334,7 +1334,7 @@
movb 8(%esp),%al
movb %al,(%edx)
xorl %eax,%eax
- movl _curpcb,%ecx /* restore trashed register */
+ movl CNAME(curpcb),%ecx /* restore trashed register */
movl %eax,PCB_ONFAULT(%ecx)
ret
@@ -1348,7 +1348,7 @@
ENTRY(copyinstr)
pushl %esi
pushl %edi
- movl _curpcb,%ecx
+ movl CNAME(curpcb),%ecx
movl $cpystrflt,PCB_ONFAULT(%ecx)
movl 12(%esp),%esi /* %esi = from */
@@ -1396,7 +1396,7 @@
cpystrflt_x:
/* set *lencopied and return %eax */
- movl _curpcb,%ecx
+ movl CNAME(curpcb),%ecx
movl $0,PCB_ONFAULT(%ecx)
movl 20(%esp),%ecx
subl %edx,%ecx
Index: i386/i386/swtch.s
===================================================================
RCS file: /usr/CVS-Repository/src/sys/i386/i386/swtch.s,v
retrieving revision 1.75
diff -u -r1.75 swtch.s
--- swtch.s 1998/07/28 17:35:09 1.75
+++ swtch.s 1998/09/01 00:35:48
@@ -269,14 +269,14 @@
/* update common_tss.tss_esp0 pointer */
#ifdef VM86
- movl _my_tr, %esi
+ movl CNAME(my_tr), %esi
#endif /* VM86 */
- movl %ecx, _common_tss + TSS_ESP0
+ movl %ecx, CNAME(common_tss) + TSS_ESP0
#ifdef VM86
- btrl %esi, _private_tss
+ btrl %esi, CNAME(private_tss)
je 1f
- movl $_common_tssd, %edi
+ movl $CNAME(common_tssd), %edi
/* move correct tss descriptor into GDT slot, then reload tr */
leal _gdt(,%esi,8), %ebx /* entry in GDT */
@@ -395,14 +395,14 @@
/* update common_tss.tss_esp0 pointer */
#ifdef VM86
- movl _my_tr, %esi
+ movl CNAME(my_tr), %esi
#endif /* VM86 */
- movl %esp, _common_tss + TSS_ESP0
+ movl %esp, CNAME(common_tss) + TSS_ESP0
#ifdef VM86
- btrl %esi, _private_tss
+ btrl %esi, CNAME(private_tss)
je 1f
- movl $_common_tssd, %edi
+ movl $CNAME(common_tssd), %edi
/* move correct tss descriptor into GDT slot, then reload tr */
leal _gdt(,%esi,8), %ebx /* entry in GDT */
@@ -455,7 +455,7 @@
ENTRY(cpu_switch)
/* switch to new process. first, save context as needed */
- movl _curproc,%ecx
+ movl CNAME(curproc),%ecx
/* if no process to save, don't bother */
testl %ecx,%ecx
@@ -492,8 +492,8 @@
#if NNPX > 0
/* have we used fp, and need a save? */
- movl _curproc,%eax
- cmpl %eax,_npxproc
+ movl CNAME(curproc),%eax
+ cmpl %eax,CNAME(npxproc)
jne 1f
addl $PCB_SAVEFPU,%ecx /* h/w bugs make saving complicated */
pushl %ecx
@@ -502,7 +502,7 @@
1:
#endif /* NNPX > 0 */
- movl $0,_curproc /* out of process */
+ movl $0,CNAME(curproc) /* out of process */
/* save is done, now choose a new process or idle */
sw1:
@@ -650,17 +650,17 @@
#endif /* SMP */
#ifdef VM86
- movl _my_tr, %esi
+ movl CNAME(my_tr), %esi
cmpl $0, PCB_EXT(%edx) /* has pcb extension? */
je 1f
- btsl %esi, _private_tss /* mark use of private tss */
+ btsl %esi, CNAME(private_tss) /* mark use of private tss */
movl PCB_EXT(%edx), %edi /* new tss descriptor */
jmp 2f
1:
#endif
/* update common_tss.tss_esp0 pointer */
- movl $_common_tss, %eax
+ movl $CNAME(common_tss), %eax
movl %edx, %ebx /* pcb */
#ifdef VM86
addl $(UPAGES * PAGE_SIZE - 16), %ebx
@@ -670,9 +670,9 @@
movl %ebx, TSS_ESP0(%eax)
#ifdef VM86
- btrl %esi, _private_tss
+ btrl %esi, CNAME(private_tss)
je 3f
- movl $_common_tssd, %edi
+ movl $CNAME(common_tssd), %edi
2:
/* move correct tss descriptor into GDT slot, then reload tr */
leal _gdt(,%esi,8), %ebx /* entry in GDT */
@@ -705,8 +705,8 @@
movl _cpuid,%eax
movb %al, P_ONCPU(%ecx)
#endif /* SMP */
- movl %edx, _curpcb
- movl %ecx, _curproc /* into next process */
+ movl %edx, CNAME(curpcb)
+ movl %ecx, CNAME(curproc) /* into next process */
#ifdef SMP
movl _cpu_lockid, %eax
@@ -800,7 +800,7 @@
* have to handle h/w bugs for reloading. We used to lose the
* parent's npx state for forks by forgetting to reload.
*/
- movl _npxproc,%eax
+ movl CNAME(npxproc),%eax
testl %eax,%eax
je 1f
Index: i386/i386/vm86bios.s
===================================================================
RCS file: /usr/CVS-Repository/src/sys/i386/i386/vm86bios.s,v
retrieving revision 1.4
diff -u -r1.4 vm86bios.s
--- vm86bios.s 1998/09/10 12:16:06 1.4
+++ vm86bios.s 1998/09/17 06:04:50
@@ -70,13 +70,13 @@
ALIGN_LOCK /* Get global lock */
popl %edx
#endif
- movl _curproc,%ecx
- pushl %ecx /* save _curproc value */
+ movl CNAME(curproc),%ecx
+ pushl %ecx /* save curproc value */
testl %ecx,%ecx
je 1f /* no process to save */
#if NNPX > 0
- cmpl %ecx,_npxproc /* do we need to save fp? */
+ cmpl %ecx,CNAME(npxproc) /* do we need to save fp? */
jne 1f
pushl %edx
movl P_ADDR(%ecx),%ecx
@@ -108,12 +108,12 @@
movl SCR_PGTABLE(%edx),%eax /* va of vm86 page table */
movl %ebx,4(%eax) /* set vm86 PTE entry 1 */
1:
- movl _curpcb,%eax
+ movl CNAME(curpcb),%eax
pushl %eax /* save curpcb */
- movl %edx,_curpcb /* set curpcb to vm86pcb */
- movl $0,_curproc /* erase curproc */
+ movl %edx,CNAME(curpcb) /* set curpcb to vm86pcb */
+ movl $0,CNAME(curproc) /* erase curproc */
- movl _my_tr,%esi
+ movl CNAME(my_tr),%esi
leal _gdt(,%esi,8),%ebx /* entry in GDT */
movl 0(%ebx),%eax
movl %eax,SCR_TSS0(%edx) /* save first word */
@@ -197,7 +197,7 @@
movl SCR_PGTABLE(%edx),%ebx /* va of vm86 page table */
movl $0,4(%ebx) /* ...clear entry 1 */
- movl _my_tr,%esi
+ movl CNAME(my_tr),%esi
leal _gdt(,%esi,8),%ebx /* entry in GDT */
movl SCR_TSS0(%edx),%eax
movl %eax,0(%ebx) /* restore first word */
cu Jo
---------------------------------------------------------------------
FreeBSD: The Power to Serve <http://www.freebsd.org>
Joachim Kuebart
Tel: +49 711 653706 I like to think.
Germany
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809171933.VAA29946>
