sync code with last fixes and improvements from OpenBSD

This commit is contained in:
purplerain 2023-06-07 21:20:56 +00:00
parent 4b78db449c
commit bf0676207f
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
2406 changed files with 6353 additions and 434004 deletions

View file

@ -64,7 +64,7 @@ rasprintf(char **buf, size_t *bufsiz, size_t offs, const char *fmt, ...)
nbufsiz = MAX(*bufsiz + 512, (size_t)len + 1);
} else
nbufsiz = MAX(offs, *bufsiz) + 512;
nbuf = realloc(*buf, nbufsiz);
if (nbuf == NULL)
return -1;

View file

@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#include <stddef.h>
__BEGIN_DECLS
size_t backtrace(void **, size_t);
char **backtrace_symbols(void *const *, size_t);

View file

@ -340,8 +340,8 @@ misc.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
misc.o: history.h rlstdc.h ansi_stdlib.h
nls.o: ansi_stdlib.h
nls.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
nls.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
nls.o: history.h rlstdc.h
nls.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
nls.o: history.h rlstdc.h
parens.o: rlconf.h
parens.o: ${BUILD_DIR}/config.h
parens.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
@ -401,10 +401,10 @@ kill.o: rlprivate.h
macro.o: rlprivate.h
mbutil.o: rlprivate.h
misc.o: rlprivate.h
nls.o: rlprivate.h
nls.o: rlprivate.h
parens.o: rlprivate.h
readline.o: rlprivate.h
rltty.o: rlprivate.h
rltty.o: rlprivate.h
search.o: rlprivate.h
signals.o: rlprivate.h
terminal.o: rlprivate.h
@ -442,12 +442,12 @@ xmalloc.o: xmalloc.h
complete.o: rlmbutil.h
display.o: rlmbutil.h
histexpand.o: rlmbutil.h
input.o: rlmbutil.h
input.o: rlmbutil.h
isearch.o: rlmbutil.h
mbutil.o: rlmbutil.h
misc.o: rlmbutil.h
readline.o: rlmbutil.h
search.o: rlmbutil.h
search.o: rlmbutil.h
text.o: rlmbutil.h
vi_mode.o: rlmbutil.h

View file

@ -64,7 +64,7 @@ AC_DEFUN(BASH_HEADER_INTTYPES,
dnl
dnl check for typedef'd symbols in header files, but allow the caller to
dnl specify the include files to be checked in addition to the default
dnl
dnl
dnl BASH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND])
AC_DEFUN(BASH_CHECK_TYPE,
[
@ -1352,7 +1352,7 @@ exit (1);
#endif
/* process control */
#if !defined (WNOHANG) || !defined (WUNTRACED)
#if !defined (WNOHANG) || !defined (WUNTRACED)
exit(1);
#endif
@ -1459,7 +1459,7 @@ AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl,
#include <sys/ioctl.h>], [int x = TIOCGWINSZ;],
bash_cv_tiocgwinsz_in_ioctl=yes,bash_cv_tiocgwinsz_in_ioctl=no)])
AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl)
if test $bash_cv_tiocgwinsz_in_ioctl = yes; then
if test $bash_cv_tiocgwinsz_in_ioctl = yes; then
AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
fi
])
@ -1471,7 +1471,7 @@ AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
#include <sys/ioctl.h>], [int x = TIOCSTAT;],
bash_cv_tiocstat_in_ioctl=yes,bash_cv_tiocstat_in_ioctl=no)])
AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl)
if test $bash_cv_tiocstat_in_ioctl = yes; then
if test $bash_cv_tiocstat_in_ioctl = yes; then
AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
fi
])
@ -1483,7 +1483,7 @@ AC_CACHE_VAL(bash_cv_fionread_in_ioctl,
#include <sys/ioctl.h>], [int x = FIONREAD;],
bash_cv_fionread_in_ioctl=yes,bash_cv_fionread_in_ioctl=no)])
AC_MSG_RESULT($bash_cv_fionread_in_ioctl)
if test $bash_cv_fionread_in_ioctl = yes; then
if test $bash_cv_fionread_in_ioctl = yes; then
AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
fi
])
@ -1500,7 +1500,7 @@ AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
[AC_TRY_COMPILE([#include <sys/types.h>], [speed_t x;],
bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)])
AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
if test $bash_cv_speed_t_in_sys_types = yes; then
if test $bash_cv_speed_t_in_sys_types = yes; then
AC_DEFINE(SPEED_T_IN_SYS_TYPES)
fi
])

View file

@ -143,13 +143,13 @@ readline.0: readline.3
readline_3.ps: readline.3
${RM} $@
${GROFF} -man < $(srcdir)/readline.3 > $@
${GROFF} -man < $(srcdir)/readline.3 > $@
history.0: history.3
history_3.ps: history.3
${RM} $@
${GROFF} -man < $(srcdir)/history.3 > $@
${GROFF} -man < $(srcdir)/history.3 > $@
clean:
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \

View file

@ -188,7 +188,7 @@ find_codeset (name, lenp)
/* This does not make sense: language has to be specified. As
an exception we allow the variable to contain only the codeset
name. Perhaps there are funny codeset names. */
if (language == cp)
if (language == cp)
{
*lenp = strlen (language);
result = language;

View file

@ -94,7 +94,7 @@ CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES) $(LOCAL_CFLAGS) $(CFLAGS
.c.so:
${RM} $@
$(SHOBJ_CC) -c $(CCFLAGS) $(SHOBJ_CFLAGS) -o $*.o $<
$(SHOBJ_CC) -c $(CCFLAGS) $(SHOBJ_CFLAGS) -o $*.o $<
$(MV) $*.o $@
# The name of the main library target.
@ -153,7 +153,7 @@ $(SHARED_HISTORY): $(SHARED_HISTOBJ) xmalloc.so
$(RM) $@
$(SHOBJ_LD) ${SHOBJ_LDFLAGS} ${SHLIB_XLDFLAGS} -o $@ $(SHARED_HISTOBJ) xmalloc.so $(SHLIB_LIBS)
# Since tilde.c is shared between readline and bash, make sure we compile
# Since tilde.c is shared between readline and bash, make sure we compile
# it with the right flags when it's built as part of readline
tilde.so: tilde.c
${RM} $@
@ -257,7 +257,7 @@ nls.so: $(topdir)/ansi_stdlib.h
nls.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
nls.o: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
nls.o: $(topdir)/rltypedefs.h
nls.o: $(topdir)/tilde.h $(topdir)/history.h $(topdir)/rlstdc.h
nls.o: $(topdir)/tilde.h $(topdir)/history.h $(topdir)/rlstdc.h
parens.so: $(topdir)/rlconf.h ${BUILD_DIR}/config.h
parens.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
parens.so: $(topdir)/rltypedefs.h
@ -318,10 +318,10 @@ kill.so: $(topdir)/rlprivate.h
macro.so: $(topdir)/rlprivate.h
mbutil.so: $(topdir)/rlprivate.h
misc.so: $(topdir)/rlprivate.h
nls.so: $(topdir)/rlprivate.h
nls.so: $(topdir)/rlprivate.h
parens.so: $(topdir)/rlprivate.h
readline.so: $(topdir)/rlprivate.h
rltty.so: $(topdir)/rlprivate.h
rltty.so: $(topdir)/rlprivate.h
search.so: $(topdir)/rlprivate.h
signals.so: $(topdir)/rlprivate.h
terminal.so: $(topdir)/rlprivate.h

View file

@ -872,7 +872,7 @@ EOF
;;
a.out-i386-linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit 0 ;;
exit 0 ;;
coff-i386)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit 0 ;;

View file

@ -323,7 +323,7 @@ case $basic_machine in
| ksr1-* | esa-ibm | fxc-alliant | *370-amdahl | sx[45]*-nec )
;;
# NOTE -- END cases added for Bash -- NOTE
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)

View file

@ -112,7 +112,7 @@ fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
@ -121,7 +121,7 @@ if [ x"$dir_arg" != x ]; then
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
@ -131,7 +131,7 @@ else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
@ -198,17 +198,17 @@ else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
@ -239,7 +239,7 @@ else
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&

View file

@ -288,7 +288,7 @@ hpux9*)
#
# SHLIB_XLDFLAGS='+b $(libdir)'
# SHLIB_LIBSUFF='sl'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
@ -318,7 +318,7 @@ hpux10*)
#
# SHLIB_XLDFLAGS='+b $(libdir)'
# SHLIB_LIBSUFF='sl'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
@ -349,7 +349,7 @@ hpux11*)
#
# SHLIB_XLDFLAGS='+b $(libdir)'
# SHLIB_LIBSUFF='sl'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
@ -400,7 +400,7 @@ sysv5uw7*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
dgux*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'

View file

@ -390,7 +390,6 @@ tilde_expand_word (filename)
return (dirname);
}
#if defined (TEST)
#undef NULL
#include <stdio.h>

View file

@ -1050,7 +1050,7 @@ Retpoline::Retpoline() {
}
void Retpoline::writeGotPlt(uint8_t *buf, const Symbol &s) const {
write64le(buf, s.getPltVA() + 17);
write64le(buf, s.getPltVA() + 21);
}
void Retpoline::writePltHeader(uint8_t *buf) const {
@ -1078,22 +1078,23 @@ void Retpoline::writePltHeader(uint8_t *buf) const {
void Retpoline::writePlt(uint8_t *buf, const Symbol &sym,
uint64_t pltEntryAddr) const {
const uint8_t insn[] = {
0x4c, 0x8b, 0x1d, 0, 0, 0, 0, // 0: mov foo@GOTPLT(%rip), %r11
0xe8, 0, 0, 0, 0, // 7: callq plt+0x20
0xe9, 0, 0, 0, 0, // c: jmp plt+0x12
0x68, 0, 0, 0, 0, // 11: pushq <relocation index>
0xe9, 0, 0, 0, 0, // 16: jmp plt+0
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, // 1b: int3; padding
0xf3, 0x0f, 0x1e, 0xfa, // 0: endbr64
0x4c, 0x8b, 0x1d, 0, 0, 0, 0, // 4: mov foo@GOTPLT(%rip), %r11
0xe8, 0, 0, 0, 0, // b: callq plt+0x20
0xe9, 0, 0, 0, 0, // 10: jmp plt+0x12
0x68, 0, 0, 0, 0, // 15: pushq <relocation index>
0xe9, 0, 0, 0, 0, // 1a: jmp plt+0
0xcc, // 1f: int3; padding
};
memcpy(buf, insn, sizeof(insn));
uint64_t off = pltEntryAddr - in.plt->getVA();
write32le(buf + 3, sym.getGotPltVA() - pltEntryAddr - 7);
write32le(buf + 8, -off - 12 + 32);
write32le(buf + 13, -off - 17 + 18);
write32le(buf + 18, sym.pltIndex);
write32le(buf + 23, -off - 27);
write32le(buf + 7, sym.getGotPltVA() - pltEntryAddr - 11);
write32le(buf + 12, -off - 16 + 32);
write32le(buf + 17, -off - 21 + 18);
write32le(buf + 22, sym.pltIndex);
write32le(buf + 27, -off - 31);
}
RetpolineZNow::RetpolineZNow() {
@ -1121,14 +1122,14 @@ void RetpolineZNow::writePltHeader(uint8_t *buf) const {
void RetpolineZNow::writePlt(uint8_t *buf, const Symbol &sym,
uint64_t pltEntryAddr) const {
const uint8_t insn[] = {
0x4c, 0x8b, 0x1d, 0, 0, 0, 0, // mov foo@GOTPLT(%rip), %r11
0xe9, 0, 0, 0, 0, // jmp plt+0
0xcc, 0xcc, 0xcc, 0xcc, // int3; padding
0xf3, 0x0f, 0x1e, 0xfa, // 0: endbr64
0x4c, 0x8b, 0x1d, 0, 0, 0, 0, // 4: mov foo@GOTPLT(%rip), %r11
0xe9, 0, 0, 0, 0, // b: jmp plt+0
};
memcpy(buf, insn, sizeof(insn));
write32le(buf + 3, sym.getGotPltVA() - pltEntryAddr - 7);
write32le(buf + 8, in.plt->getVA() - pltEntryAddr - 12);
write32le(buf + 7, sym.getGotPltVA() - pltEntryAddr - 11);
write32le(buf + 12, in.plt->getVA() - pltEntryAddr - 16);
}
static TargetInfo *getTargetInfo() {