Merge Mainline
This commit is contained in:
commit
c584f55ce0
@ -269,8 +269,10 @@ define Build/xor-image
|
||||
endef
|
||||
|
||||
define Build/check-size
|
||||
@[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(if $(1),$(1),$(IMAGE_SIZE)))))) -ge "$$(stat -c%s $@)" ] || { \
|
||||
echo "WARNING: Image file $@ is too big" >&2; \
|
||||
@imagesize="$$(stat -c%s $@)"; \
|
||||
limitsize="$$(($(subst k,* 1024,$(subst m, * 1024k,$(if $(1),$(1),$(IMAGE_SIZE))))))"; \
|
||||
[ $$limitsize -ge $$imagesize ] || { \
|
||||
echo "WARNING: Image file $@ is too big: $$imagesize > $$limitsize" >&2; \
|
||||
rm -f $@; \
|
||||
}
|
||||
endef
|
||||
|
||||
@ -143,7 +143,7 @@ EOF
|
||||
|
||||
start_dnsforwarder() {
|
||||
mkdir -p "/var/run/dnscache"
|
||||
cat > /var/run/dnscache/dnscache.conf <<EOF
|
||||
cat > "/var/run/dnscache/dnscache.conf" <<EOF
|
||||
LogOn false
|
||||
LogFileThresholdLength 102400
|
||||
LogFileFolder /var/run/dnscache
|
||||
@ -184,15 +184,15 @@ EOF
|
||||
}
|
||||
|
||||
stop_dnscache() {
|
||||
killall -9 "AdGuardHome" 2>/dev/null
|
||||
killall -9 "dnscache" 2>/dev/null
|
||||
kill -9 $(ps | grep dnscache-while.sh | grep -v "grep" | awk '{print $1}') 2>/dev/null
|
||||
killall -9 "AdGuardHome" 2>"/dev/null"
|
||||
killall -9 "dnscache" 2>"/dev/null"
|
||||
kill -9 $(ps | grep dnscache-while.sh | grep -v "grep" | awk '{print $1}') 2>"/dev/null"
|
||||
rm -rf "/var/dnscache" "/var/run/dnscache"
|
||||
echo "Stop DNS Caching"
|
||||
}
|
||||
|
||||
change_dns() {
|
||||
uci delete dhcp.@dnsmasq[0].server 2>/dev/null
|
||||
uci -q delete dhcp.@dnsmasq[0].server
|
||||
uci add_list dhcp.@dnsmasq[0].server="127.0.0.1#5333"
|
||||
uci set dhcp.@dnsmasq[0].noresolv="1"
|
||||
uci commit dhcp
|
||||
@ -200,7 +200,7 @@ change_dns() {
|
||||
}
|
||||
|
||||
revert_dns() {
|
||||
uci del_list dhcp.@dnsmasq[0].server="127.0.0.1#5333" 2>/dev/null
|
||||
uci -q del_list dhcp.@dnsmasq[0].server="127.0.0.1#5333"
|
||||
uci set dhcp.@dnsmasq[0].resolvfile="/tmp/resolv.conf.d/resolv.conf.auto"
|
||||
uci set dhcp.@dnsmasq[0].noresolv="0"
|
||||
uci commit dhcp
|
||||
@ -215,10 +215,10 @@ start(){
|
||||
uci commit firewall
|
||||
|
||||
[ "${sw_flow}" -ne "1" ] && [ "${sfe_flow}" -eq "1" ] && {
|
||||
lsmod | grep -q fast_classifier || modprobe fast_classifier 2>/dev/null
|
||||
echo "${sfe_bridge}" > "/sys/fast_classifier/skip_to_bridge_ingress"
|
||||
lsmod | grep -q fast_classifier || modprobe fast_classifier 2>"/dev/null"
|
||||
echo "${sfe_bridge}" > "/sys/fast_classifier/skip_to_bridge_ingress" 2>"/dev/null"
|
||||
if [ "${sfe_ipv6}" -eq "1" ]; then
|
||||
[ ! -f "/dev/sfe_ipv6" ] && mknod "/dev/sfe_ipv6" "c" "$(cat /sys/sfe_ipv6/debug_dev)" "0"
|
||||
[ ! -f "/dev/sfe_ipv6" ] && mknod "/dev/sfe_ipv6" "c" "$(cat "/sys/sfe_ipv6/debug_dev")" "0"
|
||||
else
|
||||
rm -f "/dev/sfe_ipv6"
|
||||
fi
|
||||
@ -232,14 +232,13 @@ start(){
|
||||
|
||||
[ "${dns_acc}" -eq "1" ] && {
|
||||
mkdir -p "/tmp/dnsmasq.d"
|
||||
wget-ssl -t "20" -T "5" "https://cdn.jsdelivr.net/gh/googlehosts/hosts@master/hosts-files/dnsmasq.conf" -O "/tmp/dnsmasq.d/dnsmasq-googlehosts.conf" &
|
||||
wget-ssl -q -t "20" -T "5" "https://cdn.jsdelivr.net/gh/googlehosts/hosts@master/hosts-files/dnsmasq.conf" -O "/tmp/dnsmasq.d/dnsmasq-googlehosts.conf" &
|
||||
}
|
||||
|
||||
if [ "${dns_caching}" -eq "1" ]; then
|
||||
stop_dnscache
|
||||
sleep 1
|
||||
rm -f "/var/log/dnscache.file"
|
||||
rm -f "/etc/AdGuardHome/data/querylog.json*"
|
||||
if [ "${dns_caching_mode}" = "1" ]; then
|
||||
start_pdnsd
|
||||
elif [ "${dns_caching_mode}" = "2" ]; then
|
||||
@ -266,10 +265,10 @@ stop(){
|
||||
uci set firewall.@defaults[0].fullcone="${fullcone_nat}"
|
||||
uci commit firewall
|
||||
|
||||
[ "${sfe_flow}" -eq "0" ] && {
|
||||
echo "0" > "/sys/fast_classifier/skip_to_bridge_ingress"
|
||||
[ "${sfe_flow}" -ne "1" ] && {
|
||||
echo "0" > "/sys/fast_classifier/skip_to_bridge_ingress" 2>"/dev/null"
|
||||
rm -f "/dev/sfe_ipv6"
|
||||
rmmod "fast_classifier" 2>/dev/null
|
||||
rmmod "fast_classifier" 2>"/dev/null"
|
||||
}
|
||||
|
||||
[ "${dns_acc}" -eq "0" ] && rm -f "/tmp/dnsmasq.d/dnsmasq-googlehosts.conf"
|
||||
|
||||
@ -14,8 +14,8 @@ set_classless_routes() {
|
||||
}
|
||||
|
||||
setup_interface() {
|
||||
echo "udhcpc: ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+}"
|
||||
ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+}
|
||||
echo "udhcpc: ip addr add $ip/${subnet:-255.255.255.0} broadcast ${broadcast:-+} dev $interface"
|
||||
ip addr add $ip/${subnet:-255.255.255.0} broadcast ${broadcast:-+} dev $interface
|
||||
|
||||
[ -n "$router" ] && [ "$router" != "0.0.0.0" ] && [ "$router" != "255.255.255.255" ] && {
|
||||
echo "udhcpc: setting default routers: $router"
|
||||
@ -41,7 +41,7 @@ setup_interface() {
|
||||
applied=
|
||||
case "$1" in
|
||||
deconfig)
|
||||
ifconfig "$interface" 0.0.0.0
|
||||
ip -4 addr flush dev "$interface"
|
||||
;;
|
||||
renew)
|
||||
setup_interface update
|
||||
|
||||
@ -326,7 +326,7 @@ start_interface() {
|
||||
append cstr "$classnr:$prio:$avgrate:$pktsize:$pktdelay:$maxrate:$qdisc:$filter" "$N"
|
||||
done
|
||||
append ${prefix}q "$(tcrules)" "$N"
|
||||
export dev_${dir}="ifconfig $dev up >&- 2>&-
|
||||
export dev_${dir}="ip link set $dev up >&- 2>&-
|
||||
tc qdisc del dev $dev root >&- 2>&-
|
||||
tc qdisc add dev $dev root handle 1: hfsc default ${class_default}0
|
||||
tc class add dev $dev parent 1: classid 1:1 hfsc sc rate ${rate}kbit ul rate ${rate}kbit"
|
||||
|
||||
@ -4,8 +4,8 @@ preinit_set_mac_address() {
|
||||
case $(board_name) in
|
||||
meraki,mr24|\
|
||||
meraki,mx60)
|
||||
mac_lan=$(mtd_get_mac_binary_ubi board-config 102)
|
||||
[ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan"
|
||||
mac_lan=$(mtd_get_mac_binary_ubi board-config 0x66)
|
||||
[ -n "$mac_lan" ] && ip link set eth0 address "$mac_lan"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ preinit_ip() {
|
||||
if [ -e "/sys/bus/mdio_bus/drivers/Infineon ADM6996/0:00" -o \
|
||||
-e "/sys/bus/mdio_bus/drivers/Marvell 88E6060/0:10" ]; then
|
||||
vconfig set_name_type DEV_PLUS_VID_NO_PAD
|
||||
ifconfig eth0 up
|
||||
ip link set eth0 up
|
||||
vconfig add eth0 1
|
||||
ifname=eth0.1
|
||||
else
|
||||
@ -15,7 +15,8 @@ preinit_ip() {
|
||||
}
|
||||
fi
|
||||
[ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
|
||||
ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
|
||||
ip addr add $pi_ip/$pi_netmask broadcast $pi_broadcast dev $pi_ifname
|
||||
ip link set $pi_ifname up
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,8 +27,8 @@ preinit_ip_deconfig() {
|
||||
if [ -e "/sys/bus/mdio_bus/drivers/Infineon ADM6996/0:00" -o \
|
||||
-e "/sys/bus/mdio_bus/drivers/Marvell 88E6060/0:10" ]; then
|
||||
vconfig rem eth0.1 2>/dev/null
|
||||
ifconfig $pi_ifname down
|
||||
ip link set $pi_ifname down
|
||||
elif [ -n "$pi_ifname" ]; then
|
||||
ifconfig $pi_ifname 0.0.0.0
|
||||
ip -4 addr flush dev $pi_ifname
|
||||
fi
|
||||
}
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
From 4d3c17975c7814884a721fe693b3adf5c426d759 Mon Sep 17 00:00:00 2001
|
||||
From: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
Date: Tue, 10 Nov 2015 22:18:39 +0100
|
||||
Subject: [RFC] serial: core: add support for boot console with arbitrary
|
||||
baud rates
|
||||
|
||||
The Arduino Yun uses a baud rate of 250000 by default. The serial is
|
||||
going over the Atmel ATmega and is used to connect to this chip.
|
||||
Without this patch Linux wants to switch the console to 9600 Baud.
|
||||
|
||||
With this patch Linux will use the configured baud rate and not a
|
||||
default one specified in uart_register_driver().
|
||||
|
||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
[rebased to 4.14, slightly reworded commit message]
|
||||
Signed-off-by: Sungbo Eo <mans0n@gorani.run>
|
||||
---
|
||||
drivers/tty/serial/serial_core.c | 6 +++++-
|
||||
include/linux/console.h | 1 +
|
||||
2 files changed, 6 insertions(+), 1 deletions(-)
|
||||
|
||||
--- a/drivers/tty/serial/serial_core.c
|
||||
+++ b/drivers/tty/serial/serial_core.c
|
||||
@@ -232,6 +232,8 @@ static int uart_port_startup(struct tty_
|
||||
if (retval == 0) {
|
||||
if (uart_console(uport) && uport->cons->cflag) {
|
||||
tty->termios.c_cflag = uport->cons->cflag;
|
||||
+ tty->termios.c_ospeed = uport->cons->baud;
|
||||
+ tty->termios.c_ispeed = uport->cons->baud;
|
||||
uport->cons->cflag = 0;
|
||||
}
|
||||
/*
|
||||
@@ -2072,8 +2074,10 @@ uart_set_options(struct uart_port *port,
|
||||
* Allow the setting of the UART parameters with a NULL console
|
||||
* too:
|
||||
*/
|
||||
- if (co)
|
||||
+ if (co) {
|
||||
co->cflag = termios.c_cflag;
|
||||
+ co->baud = baud;
|
||||
+ }
|
||||
|
||||
return 0;
|
||||
}
|
||||
--- a/include/linux/console.h
|
||||
+++ b/include/linux/console.h
|
||||
@@ -145,6 +145,7 @@ struct console {
|
||||
short flags;
|
||||
short index;
|
||||
int cflag;
|
||||
+ int baud;
|
||||
void *data;
|
||||
struct console *next;
|
||||
};
|
||||
@ -1,5 +1,5 @@
|
||||
set_preinit_iface() {
|
||||
ifconfig eth0 up
|
||||
ip link set eth0 up
|
||||
ifname=lan1
|
||||
}
|
||||
|
||||
|
||||
@ -429,7 +429,7 @@ define Device/tplink_tl-wr841n-v14
|
||||
IMAGE_SIZE := 3968k
|
||||
DEVICE_MODEL := TL-WR841N
|
||||
DEVICE_VARIANT := v14
|
||||
TPLINK_FLASHLAYOUT := 4Mmtk
|
||||
TPLINK_FLASHLAYOUT := 4MLmtk
|
||||
TPLINK_HWID := 0x08410014
|
||||
TPLINK_HWREVADD := 0x14
|
||||
IMAGES := sysupgrade.bin tftp-recovery.bin
|
||||
|
||||
@ -14,7 +14,7 @@ mt7621_bringup_dsa_master() {
|
||||
;;
|
||||
esac
|
||||
|
||||
ifconfig $masterif up
|
||||
ip link set $masterif up
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main mt7621_bringup_dsa_master
|
||||
|
||||
@ -3,8 +3,8 @@ do_b53_hack() {
|
||||
|
||||
# hack: enable switch on Lamobo R1 and reset counters
|
||||
case $(board_name) in
|
||||
lamobo,lamobo-r1)
|
||||
ifconfig eth0 up
|
||||
"lamobo,lamobo-r1")
|
||||
ip link set eth0 up
|
||||
sleep 1
|
||||
swconfig dev switch0 set reset 1
|
||||
swconfig dev switch0 set reset_mib 1
|
||||
|
||||
@ -6,16 +6,6 @@ choice
|
||||
help
|
||||
Select the version of binutils you wish to use.
|
||||
|
||||
config BINUTILS_USE_VERSION_2_29_1
|
||||
depends on !arc
|
||||
bool "Binutils 2.29.1"
|
||||
select BINUTILS_VERSION_2_29_1
|
||||
|
||||
config BINUTILS_USE_VERSION_2_31_1
|
||||
depends on !arc
|
||||
bool "Binutils 2.31.1"
|
||||
select BINUTILS_VERSION_2_31_1
|
||||
|
||||
config BINUTILS_USE_VERSION_2_32
|
||||
bool "Binutils 2.32"
|
||||
select BINUTILS_VERSION_2_32
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
config BINUTILS_VERSION_2_29_1
|
||||
bool
|
||||
|
||||
config BINUTILS_VERSION_2_31_1
|
||||
bool
|
||||
|
||||
config BINUTILS_VERSION_2_32
|
||||
bool
|
||||
|
||||
@ -13,7 +7,5 @@ config BINUTILS_VERSION_2_34
|
||||
|
||||
config BINUTILS_VERSION
|
||||
string
|
||||
default "2.29.1" if BINUTILS_VERSION_2_29_1
|
||||
default "2.31.1" if BINUTILS_VERSION_2_31_1
|
||||
default "2.32" if BINUTILS_VERSION_2_32
|
||||
default "2.34" if BINUTILS_VERSION_2_34
|
||||
|
||||
@ -15,14 +15,6 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
|
||||
TAR_OPTIONS += --exclude='*.rej'
|
||||
|
||||
ifeq ($(PKG_VERSION),2.29.1)
|
||||
PKG_HASH:=e7010a46969f9d3e53b650a518663f98a5dde3c3ae21b7d71e5e6803bc36b577
|
||||
endif
|
||||
|
||||
ifeq ($(PKG_VERSION),2.31.1)
|
||||
PKG_HASH:=5d20086ecf5752cc7d9134246e9588fa201740d540f7eb84d795b1f7a93bca86
|
||||
endif
|
||||
|
||||
ifeq ($(PKG_VERSION),2.32)
|
||||
PKG_HASH:=0ab6c55dd86a92ed561972ba15b9b70a8b9f75557f896446c82e8b36e473ee04
|
||||
endif
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
--- a/ld/Makefile.am
|
||||
+++ b/ld/Makefile.am
|
||||
@@ -57,7 +57,7 @@ endif
|
||||
# We put the scripts in the directory $(scriptdir)/ldscripts.
|
||||
# We can't put the scripts in $(datadir) because the SEARCH_DIR
|
||||
# directives need to be different for native and cross linkers.
|
||||
-scriptdir = $(tooldir)/lib
|
||||
+scriptdir = $(libdir)
|
||||
|
||||
EMUL = @EMUL@
|
||||
EMULATION_OFILES = @EMULATION_OFILES@
|
||||
--- a/ld/Makefile.in
|
||||
+++ b/ld/Makefile.in
|
||||
@@ -446,7 +446,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
|
||||
# We put the scripts in the directory $(scriptdir)/ldscripts.
|
||||
# We can't put the scripts in $(datadir) because the SEARCH_DIR
|
||||
# directives need to be different for native and cross linkers.
|
||||
-scriptdir = $(tooldir)/lib
|
||||
+scriptdir = $(libdir)
|
||||
BASEDIR = $(srcdir)/..
|
||||
BFDDIR = $(BASEDIR)/bfd
|
||||
INCDIR = $(BASEDIR)/include
|
||||
@ -1,20 +0,0 @@
|
||||
--- a/ld/emultempl/elf32.em
|
||||
+++ b/ld/emultempl/elf32.em
|
||||
@@ -1463,6 +1463,8 @@ fragment <<EOF
|
||||
&& command_line.rpath == NULL)
|
||||
{
|
||||
path = (const char *) getenv ("LD_RUN_PATH");
|
||||
+ if ((path) && (strlen (path) == 0))
|
||||
+ path = NULL;
|
||||
if (path
|
||||
&& gld${EMULATION_NAME}_search_needed (path, &n, force))
|
||||
break;
|
||||
@@ -1740,6 +1742,8 @@ gld${EMULATION_NAME}_before_allocation (
|
||||
rpath = command_line.rpath;
|
||||
if (rpath == NULL)
|
||||
rpath = (const char *) getenv ("LD_RUN_PATH");
|
||||
+ if ((rpath) && (strlen (rpath) == 0))
|
||||
+ rpath = NULL;
|
||||
|
||||
for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
|
||||
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
|
||||
@ -1,18 +0,0 @@
|
||||
--- a/bfd/elfxx-mips.c
|
||||
+++ b/bfd/elfxx-mips.c
|
||||
@@ -7871,6 +7871,7 @@ _bfd_mips_elf_create_dynamic_sections (b
|
||||
|
||||
name = SGI_COMPAT (abfd) ? "_DYNAMIC_LINK" : "_DYNAMIC_LINKING";
|
||||
bh = NULL;
|
||||
+ if (0) {
|
||||
if (!(_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr, 0,
|
||||
NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
|
||||
@@ -7883,6 +7884,7 @@ _bfd_mips_elf_create_dynamic_sections (b
|
||||
|
||||
if (! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return FALSE;
|
||||
+ }
|
||||
|
||||
if (! mips_elf_hash_table (info)->use_rld_obj_head)
|
||||
{
|
||||
@ -1,37 +0,0 @@
|
||||
--- a/bfd/config.bfd
|
||||
+++ b/bfd/config.bfd
|
||||
@@ -1186,12 +1186,12 @@ case "${targ}" in
|
||||
targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec mips_ecoff_be_vec mips_ecoff_le_vec"
|
||||
;;
|
||||
mips64*el-*-linux*)
|
||||
- targ_defvec=mips_elf32_ntrad_le_vec
|
||||
- targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec"
|
||||
+ targ_defvec=mips_elf64_trad_le_vec
|
||||
+ targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_be_vec"
|
||||
;;
|
||||
mips64*-*-linux*)
|
||||
- targ_defvec=mips_elf32_ntrad_be_vec
|
||||
- targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec"
|
||||
+ targ_defvec=mips_elf64_trad_be_vec
|
||||
+ targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_le_vec"
|
||||
;;
|
||||
mips*el-*-linux*)
|
||||
targ_defvec=mips_elf32_trad_le_vec
|
||||
--- a/ld/configure.tgt
|
||||
+++ b/ld/configure.tgt
|
||||
@@ -530,11 +530,11 @@ mips*el-*-vxworks*) targ_emul=elf32elmip
|
||||
mips*-*-vxworks*) targ_emul=elf32ebmipvxworks
|
||||
targ_extra_emuls="elf32elmipvxworks" ;;
|
||||
mips*-*-windiss) targ_emul=elf32mipswindiss ;;
|
||||
-mips64*el-*-linux-*) targ_emul=elf32ltsmipn32
|
||||
- targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
|
||||
+mips64*el-*-linux-*) targ_emul=elf64ltsmip
|
||||
+ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32ltsmip elf32btsmip elf64btsmip"
|
||||
targ_extra_libpath=$targ_extra_emuls ;;
|
||||
-mips64*-*-linux-*) targ_emul=elf32btsmipn32
|
||||
- targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
|
||||
+mips64*-*-linux-*) targ_emul=elf64btsmip
|
||||
+ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip"
|
||||
targ_extra_libpath=$targ_extra_emuls ;;
|
||||
mips*el-*-linux-*) targ_emul=elf32ltsmip
|
||||
targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
|
||||
@ -1,276 +0,0 @@
|
||||
From 3d9c8f6b3f033a6092425b7344647fb51dbed5c6 Mon Sep 17 00:00:00 2001
|
||||
From: Alan Modra <amodra@gmail.com>
|
||||
Date: Sun, 26 Aug 2018 14:23:38 +0930
|
||||
Subject: [PATCH] Delay evaluation of alignment expressions in output sections
|
||||
|
||||
git commit 702d16713 broke expressions using CONSTANT(COMMONPAGESIZE)
|
||||
in ALIGN or SUBALIGN of output section statements, because these
|
||||
optional fields were evaluated at script parse time and the patch in
|
||||
question delayed setting of config.commonpagesize. The right thing to
|
||||
do is keep the tree representation of those fields for later
|
||||
evaluation.
|
||||
|
||||
PR 23571
|
||||
* ldlang.h (section_alignment): Make it an expression tree.
|
||||
(subsection_alignment): Likewise.
|
||||
* ldlang.c (topower): Delete.
|
||||
(output_section_statement_newfunc): Adjust initialization.
|
||||
(init_os): Evaluate section_alignment.
|
||||
(lang_size_sections_1): Likewise.
|
||||
(size_input_section): Evaluate subsection_alignment.
|
||||
(lang_enter_output_section_statement): Don't evaluate here.
|
||||
(lang_new_phdr): Use exp_get_vma rather than exp_get_value_int.
|
||||
* ldexp.h (exp_get_value_int): Delete.
|
||||
(exp_get_power): Declare.
|
||||
* ldexp.c (exp_get_value_int): Delete.
|
||||
(exp_get_power): New function.
|
||||
* emultempl/pe.em (place_orphan): Build expression for section
|
||||
alignment.
|
||||
* emultempl/pep.em (place_orphan): Likewise.
|
||||
* testsuite/ld-scripts/pr23571.d,
|
||||
* testsuite/ld-scripts/pr23571.t: New test.
|
||||
* testsuite/ld-scripts/align.exp: Run it.
|
||||
---
|
||||
ld/ChangeLog | 23 +++++++++++++++++++
|
||||
ld/emultempl/pe.em | 2 +-
|
||||
ld/emultempl/pep.em | 2 +-
|
||||
ld/ldexp.c | 20 ++++++++++++++--
|
||||
ld/ldexp.h | 4 ++--
|
||||
ld/ldlang.c | 48 +++++++++++++--------------------------
|
||||
ld/ldlang.h | 4 ++--
|
||||
ld/testsuite/ld-scripts/align.exp | 4 ++++
|
||||
ld/testsuite/ld-scripts/pr23571.d | 10 ++++++++
|
||||
ld/testsuite/ld-scripts/pr23571.t | 11 +++++++++
|
||||
10 files changed, 88 insertions(+), 40 deletions(-)
|
||||
create mode 100644 ld/testsuite/ld-scripts/pr23571.d
|
||||
create mode 100644 ld/testsuite/ld-scripts/pr23571.t
|
||||
|
||||
--- a/ld/emultempl/pe.em
|
||||
+++ b/ld/emultempl/pe.em
|
||||
@@ -2165,7 +2165,7 @@ gld_${EMULATION_NAME}_place_orphan (asec
|
||||
&add_child);
|
||||
if (bfd_link_relocatable (&link_info))
|
||||
{
|
||||
- os->section_alignment = s->alignment_power;
|
||||
+ os->section_alignment = exp_intop (1U << s->alignment_power);
|
||||
os->bfd_section->alignment_power = s->alignment_power;
|
||||
}
|
||||
}
|
||||
--- a/ld/emultempl/pep.em
|
||||
+++ b/ld/emultempl/pep.em
|
||||
@@ -1962,7 +1962,7 @@ gld_${EMULATION_NAME}_place_orphan (asec
|
||||
&add_child);
|
||||
if (bfd_link_relocatable (&link_info))
|
||||
{
|
||||
- os->section_alignment = s->alignment_power;
|
||||
+ os->section_alignment = exp_intop (1U << s->alignment_power);
|
||||
os->bfd_section->alignment_power = s->alignment_power;
|
||||
}
|
||||
}
|
||||
--- a/ld/ldexp.c
|
||||
+++ b/ld/ldexp.c
|
||||
@@ -1522,10 +1522,26 @@ exp_get_vma (etree_type *tree, bfd_vma d
|
||||
return def;
|
||||
}
|
||||
|
||||
+/* Return the smallest non-negative integer such that two raised to
|
||||
+ that power is at least as large as the vma evaluated at TREE, if
|
||||
+ TREE is a non-NULL expression that can be resolved. If TREE is
|
||||
+ NULL or cannot be resolved, return -1. */
|
||||
+
|
||||
int
|
||||
-exp_get_value_int (etree_type *tree, int def, char *name)
|
||||
+exp_get_power (etree_type *tree, char *name)
|
||||
{
|
||||
- return exp_get_vma (tree, def, name);
|
||||
+ bfd_vma x = exp_get_vma (tree, -1, name);
|
||||
+ bfd_vma p2;
|
||||
+ int n;
|
||||
+
|
||||
+ if (x == (bfd_vma) -1)
|
||||
+ return -1;
|
||||
+
|
||||
+ for (n = 0, p2 = 1; p2 < x; ++n, p2 <<= 1)
|
||||
+ if (p2 == 0)
|
||||
+ break;
|
||||
+
|
||||
+ return n;
|
||||
}
|
||||
|
||||
fill_type *
|
||||
--- a/ld/ldexp.h
|
||||
+++ b/ld/ldexp.h
|
||||
@@ -229,8 +229,8 @@ void exp_print_tree
|
||||
(etree_type *);
|
||||
bfd_vma exp_get_vma
|
||||
(etree_type *, bfd_vma, char *);
|
||||
-int exp_get_value_int
|
||||
- (etree_type *, int, char *);
|
||||
+int exp_get_power
|
||||
+ (etree_type *, char *);
|
||||
fill_type *exp_get_fill
|
||||
(etree_type *, fill_type *, char *);
|
||||
bfd_vma exp_get_abs_int
|
||||
--- a/ld/ldlang.c
|
||||
+++ b/ld/ldlang.c
|
||||
@@ -1199,8 +1199,8 @@ output_section_statement_newfunc (struct
|
||||
ret = (struct out_section_hash_entry *) entry;
|
||||
memset (&ret->s, 0, sizeof (ret->s));
|
||||
ret->s.header.type = lang_output_section_statement_enum;
|
||||
- ret->s.output_section_statement.subsection_alignment = -1;
|
||||
- ret->s.output_section_statement.section_alignment = -1;
|
||||
+ ret->s.output_section_statement.subsection_alignment = NULL;
|
||||
+ ret->s.output_section_statement.section_alignment = NULL;
|
||||
ret->s.output_section_statement.block_value = 1;
|
||||
lang_list_init (&ret->s.output_section_statement.children);
|
||||
lang_statement_append (stat_ptr, &ret->s, &ret->s.header.next);
|
||||
@@ -2193,8 +2193,9 @@ init_os (lang_output_section_statement_t
|
||||
exp_init_os (s->load_base);
|
||||
|
||||
/* If supplied an alignment, set it. */
|
||||
- if (s->section_alignment != -1)
|
||||
- s->bfd_section->alignment_power = s->section_alignment;
|
||||
+ if (s->section_alignment != NULL)
|
||||
+ s->bfd_section->alignment_power = exp_get_power (s->section_alignment,
|
||||
+ "section alignment");
|
||||
}
|
||||
|
||||
/* Make sure that all output sections mentioned in an expression are
|
||||
@@ -4706,8 +4707,10 @@ size_input_section
|
||||
is greater than any seen before, then record it too. Perform
|
||||
the alignment by inserting a magic 'padding' statement. */
|
||||
|
||||
- if (output_section_statement->subsection_alignment != -1)
|
||||
- i->alignment_power = output_section_statement->subsection_alignment;
|
||||
+ if (output_section_statement->subsection_alignment != NULL)
|
||||
+ i->alignment_power
|
||||
+ = exp_get_power (output_section_statement->subsection_alignment,
|
||||
+ "subsection alignment");
|
||||
|
||||
if (o->alignment_power < i->alignment_power)
|
||||
o->alignment_power = i->alignment_power;
|
||||
@@ -5147,7 +5150,8 @@ lang_size_sections_1
|
||||
section_alignment = os->bfd_section->alignment_power;
|
||||
}
|
||||
else
|
||||
- section_alignment = os->section_alignment;
|
||||
+ section_alignment = exp_get_power (os->section_alignment,
|
||||
+ "section alignment");
|
||||
|
||||
/* Align to what the section needs. */
|
||||
if (section_alignment > 0)
|
||||
@@ -5225,7 +5229,8 @@ lang_size_sections_1
|
||||
only align according to the value in the output
|
||||
statement. */
|
||||
if (os->lma_region != os->region)
|
||||
- section_alignment = os->section_alignment;
|
||||
+ section_alignment = exp_get_power (os->section_alignment,
|
||||
+ "section alignment");
|
||||
if (section_alignment > 0)
|
||||
lma = align_power (lma, section_alignment);
|
||||
}
|
||||
@@ -6673,25 +6678,6 @@ lang_add_output (const char *name, int f
|
||||
}
|
||||
}
|
||||
|
||||
-static int
|
||||
-topower (int x)
|
||||
-{
|
||||
- unsigned int i = 1;
|
||||
- int l;
|
||||
-
|
||||
- if (x < 0)
|
||||
- return -1;
|
||||
-
|
||||
- for (l = 0; l < 32; l++)
|
||||
- {
|
||||
- if (i >= (unsigned int) x)
|
||||
- return l;
|
||||
- i <<= 1;
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
lang_output_section_statement_type *
|
||||
lang_enter_output_section_statement (const char *output_section_statement_name,
|
||||
etree_type *address_exp,
|
||||
@@ -6727,10 +6713,8 @@ lang_enter_output_section_statement (con
|
||||
einfo (_("%F%P:%pS: error: align with input and explicit align specified\n"),
|
||||
NULL);
|
||||
|
||||
- os->subsection_alignment =
|
||||
- topower (exp_get_value_int (subalign, -1, "subsection alignment"));
|
||||
- os->section_alignment =
|
||||
- topower (exp_get_value_int (align, -1, "section alignment"));
|
||||
+ os->subsection_alignment = subalign;
|
||||
+ os->section_alignment = align;
|
||||
|
||||
os->load_base = ebase;
|
||||
return os;
|
||||
@@ -7748,7 +7732,7 @@ lang_new_phdr (const char *name,
|
||||
n = (struct lang_phdr *) stat_alloc (sizeof (struct lang_phdr));
|
||||
n->next = NULL;
|
||||
n->name = name;
|
||||
- n->type = exp_get_value_int (type, 0, "program header type");
|
||||
+ n->type = exp_get_vma (type, 0, "program header type");
|
||||
n->filehdr = filehdr;
|
||||
n->phdrs = phdrs;
|
||||
n->at = at;
|
||||
--- a/ld/ldlang.h
|
||||
+++ b/ld/ldlang.h
|
||||
@@ -143,6 +143,8 @@ typedef struct lang_output_section_state
|
||||
fill_type *fill;
|
||||
union etree_union *addr_tree;
|
||||
union etree_union *load_base;
|
||||
+ union etree_union *section_alignment;
|
||||
+ union etree_union *subsection_alignment;
|
||||
|
||||
/* If non-null, an expression to evaluate after setting the section's
|
||||
size. The expression is evaluated inside REGION (above) with '.'
|
||||
@@ -153,8 +155,6 @@ typedef struct lang_output_section_state
|
||||
lang_output_section_phdr_list *phdrs;
|
||||
|
||||
unsigned int block_value;
|
||||
- int subsection_alignment; /* Alignment of components. */
|
||||
- int section_alignment; /* Alignment of start of section. */
|
||||
int constraint;
|
||||
flagword flags;
|
||||
enum section_type sectype;
|
||||
--- a/ld/testsuite/ld-scripts/align.exp
|
||||
+++ b/ld/testsuite/ld-scripts/align.exp
|
||||
@@ -53,3 +53,7 @@ if ![is_aout_format] {
|
||||
}
|
||||
run_dump_test align2c
|
||||
set LDFLAGS "$saved_LDFLAGS"
|
||||
+
|
||||
+if { [is_elf_format] && ![is_generic_elf] } {
|
||||
+ run_dump_test pr23571
|
||||
+}
|
||||
--- /dev/null
|
||||
+++ b/ld/testsuite/ld-scripts/pr23571.d
|
||||
@@ -0,0 +1,10 @@
|
||||
+#source: align2a.s
|
||||
+#ld: -T pr23571.t -z common-page-size=0x1000
|
||||
+#objdump: -h -w
|
||||
+
|
||||
+.*: +file format .*
|
||||
+
|
||||
+Sections:
|
||||
+Idx Name +Size +VMA +LMA +File off +Algn +Flags
|
||||
+ +0 \.text +[0-9a-f]* +0+1000 +0+1000 .*
|
||||
+ +1 \.data +[0-9a-f]* +0+2000 +0+2000 +[0-9a-f]* +2\*\*12 .*
|
||||
--- /dev/null
|
||||
+++ b/ld/testsuite/ld-scripts/pr23571.t
|
||||
@@ -0,0 +1,11 @@
|
||||
+SECTIONS
|
||||
+{
|
||||
+ .text CONSTANT(COMMONPAGESIZE) : {
|
||||
+ *(.text)
|
||||
+ }
|
||||
+
|
||||
+ .data : ALIGN(CONSTANT(COMMONPAGESIZE)) {
|
||||
+ *(.data)
|
||||
+ }
|
||||
+ /DISCARD/ : {*(*)}
|
||||
+}
|
||||
@ -1,22 +0,0 @@
|
||||
--- a/ld/Makefile.am
|
||||
+++ b/ld/Makefile.am
|
||||
@@ -57,7 +57,7 @@ endif
|
||||
# We put the scripts in the directory $(scriptdir)/ldscripts.
|
||||
# We can't put the scripts in $(datadir) because the SEARCH_DIR
|
||||
# directives need to be different for native and cross linkers.
|
||||
-scriptdir = $(tooldir)/lib
|
||||
+scriptdir = $(libdir)
|
||||
|
||||
EMUL = @EMUL@
|
||||
EMULATION_OFILES = @EMULATION_OFILES@
|
||||
--- a/ld/Makefile.in
|
||||
+++ b/ld/Makefile.in
|
||||
@@ -563,7 +563,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
|
||||
# We put the scripts in the directory $(scriptdir)/ldscripts.
|
||||
# We can't put the scripts in $(datadir) because the SEARCH_DIR
|
||||
# directives need to be different for native and cross linkers.
|
||||
-scriptdir = $(tooldir)/lib
|
||||
+scriptdir = $(libdir)
|
||||
BASEDIR = $(srcdir)/..
|
||||
BFDDIR = $(BASEDIR)/bfd
|
||||
INCDIR = $(BASEDIR)/include
|
||||
@ -1,20 +0,0 @@
|
||||
--- a/ld/emultempl/elf32.em
|
||||
+++ b/ld/emultempl/elf32.em
|
||||
@@ -1471,6 +1471,8 @@ fragment <<EOF
|
||||
&& command_line.rpath == NULL)
|
||||
{
|
||||
path = (const char *) getenv ("LD_RUN_PATH");
|
||||
+ if ((path) && (strlen (path) == 0))
|
||||
+ path = NULL;
|
||||
if (path
|
||||
&& gld${EMULATION_NAME}_search_needed (path, &n, force))
|
||||
break;
|
||||
@@ -1751,6 +1753,8 @@ gld${EMULATION_NAME}_before_allocation (
|
||||
rpath = command_line.rpath;
|
||||
if (rpath == NULL)
|
||||
rpath = (const char *) getenv ("LD_RUN_PATH");
|
||||
+ if ((rpath) && (strlen (rpath) == 0))
|
||||
+ rpath = NULL;
|
||||
|
||||
for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
|
||||
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
|
||||
@ -1,18 +0,0 @@
|
||||
--- a/bfd/elfxx-mips.c
|
||||
+++ b/bfd/elfxx-mips.c
|
||||
@@ -7888,6 +7888,7 @@ _bfd_mips_elf_create_dynamic_sections (b
|
||||
|
||||
name = SGI_COMPAT (abfd) ? "_DYNAMIC_LINK" : "_DYNAMIC_LINKING";
|
||||
bh = NULL;
|
||||
+ if (0) {
|
||||
if (!(_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr, 0,
|
||||
NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
|
||||
@@ -7900,6 +7901,7 @@ _bfd_mips_elf_create_dynamic_sections (b
|
||||
|
||||
if (! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return FALSE;
|
||||
+ }
|
||||
|
||||
if (! mips_elf_hash_table (info)->use_rld_obj_head)
|
||||
{
|
||||
@ -1,37 +0,0 @@
|
||||
--- a/bfd/config.bfd
|
||||
+++ b/bfd/config.bfd
|
||||
@@ -913,12 +913,12 @@ case "${targ}" in
|
||||
targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec mips_ecoff_be_vec mips_ecoff_le_vec"
|
||||
;;
|
||||
mips64*el-*-linux*)
|
||||
- targ_defvec=mips_elf32_ntrad_le_vec
|
||||
- targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec"
|
||||
+ targ_defvec=mips_elf64_trad_le_vec
|
||||
+ targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_be_vec"
|
||||
;;
|
||||
mips64*-*-linux*)
|
||||
- targ_defvec=mips_elf32_ntrad_be_vec
|
||||
- targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec"
|
||||
+ targ_defvec=mips_elf64_trad_be_vec
|
||||
+ targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_le_vec"
|
||||
;;
|
||||
mips*el-*-linux*)
|
||||
targ_defvec=mips_elf32_trad_le_vec
|
||||
--- a/ld/configure.tgt
|
||||
+++ b/ld/configure.tgt
|
||||
@@ -464,11 +464,11 @@ mips*el-*-vxworks*) targ_emul=elf32elmip
|
||||
mips*-*-vxworks*) targ_emul=elf32ebmipvxworks
|
||||
targ_extra_emuls="elf32elmipvxworks" ;;
|
||||
mips*-*-windiss) targ_emul=elf32mipswindiss ;;
|
||||
-mips64*el-*-linux-*) targ_emul=elf32ltsmipn32
|
||||
- targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
|
||||
+mips64*el-*-linux-*) targ_emul=elf64ltsmip
|
||||
+ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32ltsmip elf32btsmip elf64btsmip"
|
||||
targ_extra_libpath=$targ_extra_emuls ;;
|
||||
-mips64*-*-linux-*) targ_emul=elf32btsmipn32
|
||||
- targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
|
||||
+mips64*-*-linux-*) targ_emul=elf64btsmip
|
||||
+ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip"
|
||||
targ_extra_libpath=$targ_extra_emuls ;;
|
||||
mips*el-*-linux-*) targ_emul=elf32ltsmip
|
||||
targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
|
||||
@ -124,6 +124,12 @@ char md5salt_boot[MD5SUM_LEN] = {
|
||||
static struct flash_layout layouts[] = {
|
||||
{
|
||||
.id = "4Mmtk",
|
||||
.fw_max_len = 0x3c0000,
|
||||
.kernel_la = 0x80000000,
|
||||
.kernel_ep = 0x80000000,
|
||||
.rootfs_ofs = 0x140000,
|
||||
}, {
|
||||
.id = "4MLmtk",
|
||||
.fw_max_len = 0x3d0000,
|
||||
.kernel_la = 0x80000000,
|
||||
.kernel_ep = 0x80000000,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user