Hello!
Can someone please help me in building debug version of klibc ?
I've cloned git://git.kernel.org/pub/scm/libs/klibc/klibc.git , but
failed to build it with debug info
added "-g" to HOSTCFLAGS in Makefile, but
$ make -j KLIBCKERNELSRC=`pwd`/../linux-2.6/usr
still strips every debug symbol , and i'm failed to change
scripts/Kbuild.klibc and Makefile to remove strip usage
klibc$ find . -name fstype | xargs file
./usr/kinit/fstype: directory
./usr/kinit/fstype/static/fstype: ELF 64-bit MSB executable, SPARC V9,
relaxed memory ordering, version 1 (SYSV), statically linked, stripped
./usr/kinit/fstype/shared/fstype: ELF 64-bit MSB executable, SPARC V9,
relaxed memory ordering, version 1 (SYSV), statically linked,
interpreter /lib/klibc-M67ne2AU3wnuYln_9h2L1vfH5J0.so, stripped
I started to get segfault in fstype:
linux-2.6$ make install
...
DEPMOD 4.15.0-rc5-00149-g5aa90a845892
sh ./arch/sparc/boot/install.sh 4.15.0-rc5-00149-g5aa90a845892
arch/sparc/boot/zImage \
System.map "/boot"
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal
4.15.0-rc5-00149-g5aa90a845892
/boot/vmlinuz-4.15.0-rc5-00149-g5aa90a845892
run-parts: executing /etc/kernel/postinst.d/initramfs-tools
4.15.0-rc5-00149-g5aa90a845892
/boot/vmlinuz-4.15.0-rc5-00149-g5aa90a845892
update-initramfs: Generating /boot/initrd.img-4.15.0-rc5-00149-g5aa90a845892
Segmentation fault
run-parts: executing /etc/kernel/postinst.d/zz-update-grub
4.15.0-rc5-00149-g5aa90a845892
/boot/vmlinuz-4.15.0-rc5-00149-g5aa90a845892
Dec 30 12:51:06 ttip kernel: fstype[162686]: segfault at 38 ip
000000008001069c (rpc 0000000080004820) sp 000007feffdf53a1 error 1 in
klibc-g_9mplOvk_73CeIA8YN-t9vhxyc.so[80000000+14000]
linux-2.6$ gdb -q -c core.164896
[New LWP 164896]
Core was generated by `/usr/lib/klibc/bin/fstype /dev/vdiska2'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000000008001069c in ?? ()
linux-2.6$ $ find /usr -name fstype | xargs file
/usr/lib/klibc/bin/fstype: ELF 64-bit MSB executable, SPARC V9,
relaxed memory ordering, version 1 (SYSV), statically linked,
interpreter /lib/klibc-g_9mplOvk_73CeIA8YN-t9vhxyc.so, stripped
linux-2.6# file -s /dev/vdiska2
/dev/vdiska2: Linux rev 1.0 ext4 filesystem data,
UUID=f2eda779-5310-4af2-b48a-b43db51c0961 (needs journal recovery)
(extents) (64bit) (large files) (huge files)
$ dpkg -S /usr/lib/klibc/bin/fstype
klibc-utils: /usr/lib/klibc/bin/fstype
$ dpkg -l klibc-utils
||/ Name Version
Architecture Description
+++-==================================-======================-======================-========================================================================ii
klibc-utils 2.0.4-10 sparc64
small utilities built with klibc for early boot
$ apt show klibc-utils
Package: klibc-utils
Version: 2.0.4-10
Priority: optional
Section: libs
Source: klibc
Maintainer: maximilian attems <maks at debian.org>
Installed-Size: 522 kB
Depends: libklibc (= 2.0.4-10)
Breaks: initramfs-tools (<< 0.123~)
Homepage: https://git.kernel.org/cgit/libs/klibc/klibc.git
Download-Size: 107 kB
APT-Manual-Installed: no
APT-Sources: http://ftp.ports.debian.org/debian-ports unstable/main
sparc64 Packages
Description: small utilities built with klibc for early boot
This package contains a collection of programs that are linked
against klibc. These duplicate some of the functionality of a
regular Linux toolset, but are typically much smaller than their
full-function counterparts. They are intended for inclusion in
initramfs images and embedded systems.
Hi Anatoly On Sat, Dec 30, 2017 at 01:54:05PM +0300, Anatoly Pugachev wrote:> Hello! > > Can someone please help me in building debug version of klibc ? > > I've cloned git://git.kernel.org/pub/scm/libs/klibc/klibc.git , but > failed to build it with debug info > > added "-g" to HOSTCFLAGS in Makefile, butHOSTCFLAGS is used when building tools running on your build machine. Try something like this (untested, whitespace damaged): diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index f500d535..3e8124f7 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -69,7 +69,7 @@ include $(srctree)/scripts/Kbuild.include KLIBCREQFLAGS := $(call cc-option, -fno-stack-protector, ) \ $(call cc-option, -fwrapv, ) KLIBCARCHREQFLAGS :-KLIBCOPTFLAGS :+KLIBCOPTFLAGS := -g KLIBCWARNFLAGS := -W -Wall -Wno-sign-compare -Wno-unused-parameter KLIBCSHAREDFLAGS : KLIBCBITSIZE : If you use make V=1 then you should be able to see the full gcc command line, where -g should be included with theabove fix. Sam
On Sat, 30 Dec 2017 13:54:05 +0300, Anatoly Pugachev said:> Hello! > > Can someone please help me in building debug version of klibc ? > > I've cloned git://git.kernel.org/pub/scm/libs/klibc/klibc.git , but > failed to build it with debug info > > added "-g" to HOSTCFLAGS in Makefile, butHint: HOSTCFLAGS is applied to code that needs to run on the machine that's doing the build, not the target code. So for instance, if I'm cross-compiling on an x86_64 for an ARM target (which I do quite a bit, building Lede router images for my wireless), HOSTCFLAGS is applied to any x86_64 utility code that gets built. I don't know what code is in klibc, but an example in the kernel source tree would be 'objtool' - that runs on the host system during the build, not at runtime.> I started to get segfault in fstype:> linux-2.6$ make install...> DEPMOD 4.15.0-rc5-00149-g5aa90a845892 > sh ./arch/sparc/boot/install.sh 4.15.0-rc5-00149-g5aa90a845892 arch/sparc/boot/zImage \ > System.map "/boot"What directory did you do that in? It looks like you're trying to install a whole new kernel image, not a new initramfs that has an updated klibc on it. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 486 bytes Desc: not available URL: <http://www.zytor.com/pipermail/klibc/attachments/20171230/94407224/attachment.sig>
On Sat, Dec 30, 2017 at 2:30 PM, Sam Ravnborg <sam at ravnborg.org> wrote:> Hi Anatoly > > On Sat, Dec 30, 2017 at 01:54:05PM +0300, Anatoly Pugachev wrote: >> Hello! >> >> Can someone please help me in building debug version of klibc ? >> >> I've cloned git://git.kernel.org/pub/scm/libs/klibc/klibc.git , but >> failed to build it with debug info >> >> added "-g" to HOSTCFLAGS in Makefile, but > > HOSTCFLAGS is used when building tools running on your build machine. > > Try something like this (untested, whitespace damaged): > > diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc > index f500d535..3e8124f7 100644 > --- a/scripts/Kbuild.klibc > +++ b/scripts/Kbuild.klibc > @@ -69,7 +69,7 @@ include $(srctree)/scripts/Kbuild.include > KLIBCREQFLAGS := $(call cc-option, -fno-stack-protector, ) \ > $(call cc-option, -fwrapv, ) > KLIBCARCHREQFLAGS :> -KLIBCOPTFLAGS :> +KLIBCOPTFLAGS := -g > KLIBCWARNFLAGS := -W -Wall -Wno-sign-compare -Wno-unused-parameter > KLIBCSHAREDFLAGS :> KLIBCBITSIZE :> > If you use make V=1 then you should be able to see the > full gcc command line, where -g should be included with > theabove fix.Sam, thanks! I did notice that later as well, but I've changed KLIBCCFLAGS to include "-g" and changed strip to echo: mator at ttip:~/klibc$ git diff diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index f500d535..40cbfd60 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -74,7 +74,7 @@ KLIBCWARNFLAGS := -W -Wall -Wno-sign-compare -Wno-unused-parameter KLIBCSHAREDFLAGS : KLIBCBITSIZE : KLIBCLDFLAGS :-KLIBCCFLAGS :+KLIBCCFLAGS := -g # Defaults for arch to override KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)/arch/$(KLIBCARCH)/include @@ -99,7 +99,7 @@ KLIBCAR := $(AR) klibc-ar = $(KLIBCAR) $(if $(KBUILD_REPRODUCIBLE),$(2),$(1)) KLIBCRANLIB := $(call klibc-ar,s,Ds) -KLIBCSTRIP := $(STRIP) +KLIBCSTRIP := echo KLIBCNM := $(NM) KLIBCOBJCOPY := $(OBJCOPY) KLIBCOBJDUMP := $(OBJDUMP) @@ -126,7 +126,7 @@ KLIBCCPPFLAGS += $(KLIBCDEFS) KLIBCCFLAGS += $(KLIBCCPPFLAGS) $(KLIBCREQFLAGS) $(KLIBCARCHREQFLAGS) \ $(KLIBCOPTFLAGS) $(KLIBCWARNFLAGS) KLIBCAFLAGS += -D__ASSEMBLY__ $(KLIBCCFLAGS) -KLIBCSTRIPFLAGS += --strip-all -R .comment -R .note +#KLIBCSTRIPFLAGS += --strip-all -R .comment -R .note KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-libgcc) KLIBCLIBGCC ?= $(KLIBCLIBGCC_DEF) mator at ttip:~/klibc$ this helped me to produce exec with debug info and stack trace: (gdb) file ./usr/kinit/fstype/static/fstype Reading symbols from ./usr/kinit/fstype/static/fstype...done. (gdb) run Starting program: /home/mator/klibc/usr/kinit/fstype/static/fstype Program received signal SIGSEGV, Segmentation fault. __syscall_common () at usr/klibc/arch/sparc64/syscall.S:15 15 st %o0,[%g4] (gdb) bt #0 __syscall_common () at usr/klibc/arch/sparc64/syscall.S:15 #1 0x00000000001010d4 in identify_fs () #2 0x00000000001001f0 in main () PS: added sparclinux at vger , first thread message is http://www.zytor.com/pipermail/klibc/2017-December/003962.html
On Sat, Dec 30, 2017 at 3:00 PM, <valdis.kletnieks at vt.edu> wrote:> On Sat, 30 Dec 2017 13:54:05 +0300, Anatoly Pugachev said: >> Hello! >> >> Can someone please help me in building debug version of klibc ? >> >> I've cloned git://git.kernel.org/pub/scm/libs/klibc/klibc.git , but >> failed to build it with debug info >> >> added "-g" to HOSTCFLAGS in Makefile, but > > Hint: HOSTCFLAGS is applied to code that needs to run on the machine that's > doing the build, not the target code. So for instance, if I'm cross-compiling on > an x86_64 for an ARM target (which I do quite a bit, building Lede router images > for my wireless), HOSTCFLAGS is applied to any x86_64 utility code that gets > built. I don't know what code is in klibc, but an example in the kernel source > tree would be 'objtool' - that runs on the host system during the build, not at runtime. > >> I started to get segfault in fstype: > >> linux-2.6$ make install > ... >> DEPMOD 4.15.0-rc5-00149-g5aa90a845892 >> sh ./arch/sparc/boot/install.sh 4.15.0-rc5-00149-g5aa90a845892 arch/sparc/boot/zImage \ >> System.map "/boot" > > What directory did you do that in? It looks like you're trying to install a whole > new kernel image, not a new initramfs that has an updated klibc on it.Valdis, it's usual git kernel compile and install. And it's the first time I started to get segfault from fstype. git kernel from git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git local directory where do i build it is ~/linux-2.6 , my own config. Worked fine for more than 100th times. So, i'm doing "make modules_install && make install" in this directory which doing right about to copy vmlinuz, System.map, kernel config file to /boot and generate initrd there and updating boot loader (grub2) config file.
James Clarke
2017-Dec-30 23:48 UTC
[klibc] [PATCH] Fix sparc assembly when compiled as PIC
Some distributions default to PIE for their compilers, which on sparc is passed
on to the assembler. Since the behaviour of %hi/%lo changes under PIC to become
GOT offsets, the current assembly files need adapting to not try to use a GOT
offset as an absolute address.
---
usr/include/arch/sparc/machine/asm.h | 15 +++++++++++++--
usr/include/arch/sparc64/machine/asm.h | 1 +
usr/include/arch/sparc64/machine/frame.h | 1 +
usr/klibc/arch/sparc/pipe.S | 6 +++---
usr/klibc/arch/sparc/syscall.S | 6 ++++--
usr/klibc/arch/sparc/sysfork.S | 6 ++++--
usr/klibc/arch/sparc64/pipe.S | 6 +++---
usr/klibc/arch/sparc64/syscall.S | 6 ++++--
usr/klibc/arch/sparc64/sysfork.S | 6 ++++--
9 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/usr/include/arch/sparc/machine/asm.h
b/usr/include/arch/sparc/machine/asm.h
index 04fe9b1b..fd9ef1ef 100644
--- a/usr/include/arch/sparc/machine/asm.h
+++ b/usr/include/arch/sparc/machine/asm.h
@@ -61,7 +61,7 @@
#endif
#define _ASM_LABEL(name) name
-#ifdef PIC
+#ifdef __PIC__
/*
* PIC_PROLOGUE() is akin to the compiler generated function prologue for
* PIC code. It leaves the address of the Global Offset Table in DEST,
@@ -83,12 +83,20 @@
0: \
add dest,%o7,dest; \
mov tmp, %o7
+#define SET(var,base,dest) \
+ sethi %gdop_hix22(var), dest; \
+ xor dest, %gdop_lox10(var), dest; \
+ ldx [base + dest], dest, %gdop(var)
#else
#define PIC_PROLOGUE(dest,tmp) \
mov %o7,tmp; 3: call 4f; nop; 4: \
sethi %hi(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
or dest,%lo(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
add dest,%o7,dest; mov tmp,%o7
+#define SET(var,base,dest) \
+ sethi %gdop_hix22(var), dest; \
+ xor dest, %gdop_lox10(var), dest; \
+ ld [base + dest], dest, %gdop(var)
#endif
/*
@@ -106,7 +114,10 @@
#endif
#else
#define PIC_PROLOGUE(dest,tmp)
-#define PICCY_OFFSET(var,dest,tmp)
+#define SET(var,base,dest) \
+ sethi %hi(var), dest; \
+ or dest, %lo(var), dest
+#define PICCY_SET(var,dest,tmp) SET(var,tmp,dest)
#endif
#define FTYPE(x) .type x, at function
diff --git a/usr/include/arch/sparc64/machine/asm.h
b/usr/include/arch/sparc64/machine/asm.h
new file mode 100644
index 00000000..394ba865
--- /dev/null
+++ b/usr/include/arch/sparc64/machine/asm.h
@@ -0,0 +1 @@
+#include "../../sparc/machine/asm.h"
diff --git a/usr/include/arch/sparc64/machine/frame.h
b/usr/include/arch/sparc64/machine/frame.h
new file mode 100644
index 00000000..79beea6d
--- /dev/null
+++ b/usr/include/arch/sparc64/machine/frame.h
@@ -0,0 +1 @@
+#include "../../sparc/machine/frame.h"
diff --git a/usr/klibc/arch/sparc/pipe.S b/usr/klibc/arch/sparc/pipe.S
index a8abf3c3..7ff09074 100644
--- a/usr/klibc/arch/sparc/pipe.S
+++ b/usr/klibc/arch/sparc/pipe.S
@@ -5,6 +5,7 @@
* they return the two file descriptors in %o0 and %o1.
*/
+#include <machine/asm.h>
#include <asm/unistd.h>
.globl pipe
@@ -15,9 +16,8 @@ pipe:
or %o0, 0, %g4
t 0x10
bcc 1f
- nop
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0,[%g4]
retl
mov -1, %o0
diff --git a/usr/klibc/arch/sparc/syscall.S b/usr/klibc/arch/sparc/syscall.S
index c0273f77..52a8583b 100644
--- a/usr/klibc/arch/sparc/syscall.S
+++ b/usr/klibc/arch/sparc/syscall.S
@@ -4,14 +4,16 @@
* Common system-call stub; %g1 already set to syscall number
*/
+#include <machine/asm.h>
+
.globl __syscall_common
.type __syscall_common,#function
.align 4
__syscall_common:
t 0x10
bcc 1f
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0,[%g4]
mov -1, %o0
1:
diff --git a/usr/klibc/arch/sparc/sysfork.S b/usr/klibc/arch/sparc/sysfork.S
index a66c76e9..3787b944 100644
--- a/usr/klibc/arch/sparc/sysfork.S
+++ b/usr/klibc/arch/sparc/sysfork.S
@@ -8,6 +8,8 @@
* Common system-call stub; %g1 already set to syscall number
*/
+#include <machine/asm.h>
+
.globl __syscall_forkish
.type __syscall_forkish,#function
.align 4
@@ -16,8 +18,8 @@ __syscall_forkish:
sub %o1, 1, %o1
bcc,a 1f
and %o0, %o1, %o0
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0,[%g4]
mov -1, %o0
1:
diff --git a/usr/klibc/arch/sparc64/pipe.S b/usr/klibc/arch/sparc64/pipe.S
index c63b20f7..cedc6402 100644
--- a/usr/klibc/arch/sparc64/pipe.S
+++ b/usr/klibc/arch/sparc64/pipe.S
@@ -5,6 +5,7 @@
* they return the two file descriptors in %o0 and %o1.
*/
+#include <machine/asm.h>
#include <asm/unistd.h>
.globl pipe
@@ -15,9 +16,8 @@ pipe:
or %o0, 0, %g4
t 0x6d
bcc %xcc, 1f
- nop
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0,[%g4]
retl
mov -1, %o0
diff --git a/usr/klibc/arch/sparc64/syscall.S b/usr/klibc/arch/sparc64/syscall.S
index 7ab9d95f..c84c9ae5 100644
--- a/usr/klibc/arch/sparc64/syscall.S
+++ b/usr/klibc/arch/sparc64/syscall.S
@@ -4,14 +4,16 @@
* Common system-call stub; %g1 already set to syscall number
*/
+#include <machine/asm.h>
+
.globl __syscall_common
.type __syscall_common,#function
.align 4
__syscall_common:
t 0x6d
bcc %xcc, 1f
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0,[%g4]
1:
retl
diff --git a/usr/klibc/arch/sparc64/sysfork.S b/usr/klibc/arch/sparc64/sysfork.S
index 2eed659e..a0c13340 100644
--- a/usr/klibc/arch/sparc64/sysfork.S
+++ b/usr/klibc/arch/sparc64/sysfork.S
@@ -8,6 +8,8 @@
* Common system-call stub; %g1 already set to syscall number
*/
+#include <machine/asm.h>
+
.globl __syscall_forkish
.type __syscall_forkish,#function
.align 4
@@ -16,8 +18,8 @@ __syscall_forkish:
sub %o1, 1, %o1
bcc,a %xcc, 1f
and %o0, %o1, %o0
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0, [%g4]
retl
mov -1, %o0
--
2.15.1
James Clarke
2018-Jul-18 22:11 UTC
[klibc] [PATCH v2] Fix sparc assembly when compiled as PIC
Some distributions default to PIE for their compilers, which on sparc is passed
on to the assembler. Since the behaviour of %hi/%lo changes under PIC to become
GOT offsets, the current assembly files need adapting to not try to use a GOT
offset as an absolute address.
---
Changes since v1:
* Don't put the start of PIC_PROLOGUE in the delay slot of the branch
after the pipe syscall, since that clobbers %g4 which is used as a
saved register on the success path.
usr/include/arch/sparc/machine/asm.h | 15 +++++++++++++--
usr/include/arch/sparc64/machine/asm.h | 1 +
usr/include/arch/sparc64/machine/frame.h | 1 +
usr/klibc/arch/sparc/pipe.S | 5 +++--
usr/klibc/arch/sparc/syscall.S | 6 ++++--
usr/klibc/arch/sparc/sysfork.S | 6 ++++--
usr/klibc/arch/sparc64/pipe.S | 5 +++--
usr/klibc/arch/sparc64/syscall.S | 6 ++++--
usr/klibc/arch/sparc64/sysfork.S | 6 ++++--
9 files changed, 37 insertions(+), 14 deletions(-)
diff --git a/usr/include/arch/sparc/machine/asm.h
b/usr/include/arch/sparc/machine/asm.h
index 04fe9b1b..fd9ef1ef 100644
--- a/usr/include/arch/sparc/machine/asm.h
+++ b/usr/include/arch/sparc/machine/asm.h
@@ -61,7 +61,7 @@
#endif
#define _ASM_LABEL(name) name
-#ifdef PIC
+#ifdef __PIC__
/*
* PIC_PROLOGUE() is akin to the compiler generated function prologue for
* PIC code. It leaves the address of the Global Offset Table in DEST,
@@ -83,12 +83,20 @@
0: \
add dest,%o7,dest; \
mov tmp, %o7
+#define SET(var,base,dest) \
+ sethi %gdop_hix22(var), dest; \
+ xor dest, %gdop_lox10(var), dest; \
+ ldx [base + dest], dest, %gdop(var)
#else
#define PIC_PROLOGUE(dest,tmp) \
mov %o7,tmp; 3: call 4f; nop; 4: \
sethi %hi(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
or dest,%lo(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
add dest,%o7,dest; mov tmp,%o7
+#define SET(var,base,dest) \
+ sethi %gdop_hix22(var), dest; \
+ xor dest, %gdop_lox10(var), dest; \
+ ld [base + dest], dest, %gdop(var)
#endif
/*
@@ -106,7 +114,10 @@
#endif
#else
#define PIC_PROLOGUE(dest,tmp)
-#define PICCY_OFFSET(var,dest,tmp)
+#define SET(var,base,dest) \
+ sethi %hi(var), dest; \
+ or dest, %lo(var), dest
+#define PICCY_SET(var,dest,tmp) SET(var,tmp,dest)
#endif
#define FTYPE(x) .type x, at function
diff --git a/usr/include/arch/sparc64/machine/asm.h
b/usr/include/arch/sparc64/machine/asm.h
new file mode 100644
index 00000000..394ba865
--- /dev/null
+++ b/usr/include/arch/sparc64/machine/asm.h
@@ -0,0 +1 @@
+#include "../../sparc/machine/asm.h"
diff --git a/usr/include/arch/sparc64/machine/frame.h
b/usr/include/arch/sparc64/machine/frame.h
new file mode 100644
index 00000000..79beea6d
--- /dev/null
+++ b/usr/include/arch/sparc64/machine/frame.h
@@ -0,0 +1 @@
+#include "../../sparc/machine/frame.h"
diff --git a/usr/klibc/arch/sparc/pipe.S b/usr/klibc/arch/sparc/pipe.S
index a8abf3c3..e278bda5 100644
--- a/usr/klibc/arch/sparc/pipe.S
+++ b/usr/klibc/arch/sparc/pipe.S
@@ -5,6 +5,7 @@
* they return the two file descriptors in %o0 and %o1.
*/
+#include <machine/asm.h>
#include <asm/unistd.h>
.globl pipe
@@ -16,8 +17,8 @@ pipe:
t 0x10
bcc 1f
nop
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0,[%g4]
retl
mov -1, %o0
diff --git a/usr/klibc/arch/sparc/syscall.S b/usr/klibc/arch/sparc/syscall.S
index c0273f77..52a8583b 100644
--- a/usr/klibc/arch/sparc/syscall.S
+++ b/usr/klibc/arch/sparc/syscall.S
@@ -4,14 +4,16 @@
* Common system-call stub; %g1 already set to syscall number
*/
+#include <machine/asm.h>
+
.globl __syscall_common
.type __syscall_common,#function
.align 4
__syscall_common:
t 0x10
bcc 1f
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0,[%g4]
mov -1, %o0
1:
diff --git a/usr/klibc/arch/sparc/sysfork.S b/usr/klibc/arch/sparc/sysfork.S
index a66c76e9..3787b944 100644
--- a/usr/klibc/arch/sparc/sysfork.S
+++ b/usr/klibc/arch/sparc/sysfork.S
@@ -8,6 +8,8 @@
* Common system-call stub; %g1 already set to syscall number
*/
+#include <machine/asm.h>
+
.globl __syscall_forkish
.type __syscall_forkish,#function
.align 4
@@ -16,8 +18,8 @@ __syscall_forkish:
sub %o1, 1, %o1
bcc,a 1f
and %o0, %o1, %o0
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0,[%g4]
mov -1, %o0
1:
diff --git a/usr/klibc/arch/sparc64/pipe.S b/usr/klibc/arch/sparc64/pipe.S
index c63b20f7..cb5c2c79 100644
--- a/usr/klibc/arch/sparc64/pipe.S
+++ b/usr/klibc/arch/sparc64/pipe.S
@@ -5,6 +5,7 @@
* they return the two file descriptors in %o0 and %o1.
*/
+#include <machine/asm.h>
#include <asm/unistd.h>
.globl pipe
@@ -16,8 +17,8 @@ pipe:
t 0x6d
bcc %xcc, 1f
nop
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0,[%g4]
retl
mov -1, %o0
diff --git a/usr/klibc/arch/sparc64/syscall.S b/usr/klibc/arch/sparc64/syscall.S
index 7ab9d95f..c84c9ae5 100644
--- a/usr/klibc/arch/sparc64/syscall.S
+++ b/usr/klibc/arch/sparc64/syscall.S
@@ -4,14 +4,16 @@
* Common system-call stub; %g1 already set to syscall number
*/
+#include <machine/asm.h>
+
.globl __syscall_common
.type __syscall_common,#function
.align 4
__syscall_common:
t 0x6d
bcc %xcc, 1f
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0,[%g4]
1:
retl
diff --git a/usr/klibc/arch/sparc64/sysfork.S b/usr/klibc/arch/sparc64/sysfork.S
index 2eed659e..a0c13340 100644
--- a/usr/klibc/arch/sparc64/sysfork.S
+++ b/usr/klibc/arch/sparc64/sysfork.S
@@ -8,6 +8,8 @@
* Common system-call stub; %g1 already set to syscall number
*/
+#include <machine/asm.h>
+
.globl __syscall_forkish
.type __syscall_forkish,#function
.align 4
@@ -16,8 +18,8 @@ __syscall_forkish:
sub %o1, 1, %o1
bcc,a %xcc, 1f
and %o0, %o1, %o0
- sethi %hi(errno), %g4
- or %g4, %lo(errno), %g4
+ PIC_PROLOGUE(%g1,%g4)
+ SET(errno,%g1,%g4)
st %o0, [%g4]
retl
mov -1, %o0
--
2.18.0