diff --git a/package/boot/uboot-mediatek/Makefile b/package/boot/uboot-mediatek/Makefile index 30f0ca8cbd..344d96ea01 100644 --- a/package/boot/uboot-mediatek/Makefile +++ b/package/boot/uboot-mediatek/Makefile @@ -1,8 +1,8 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk -PKG_VERSION:=2024.07 -PKG_HASH:=f591da9ab90ef3d6b3d173766d0ddff90c4ed7330680897486117df390d83c8f +PKG_VERSION:=2024.10 +PKG_HASH:=b28daf4ac17e43156363078bf510297584137f6df50fced9b12df34f61a92fb0 PKG_BUILD_DEPENDS:=!(TARGET_ramips||TARGET_mediatek_mt7623):arm-trusted-firmware-tools/host UBOOT_USE_INTREE_DTC:=1 @@ -922,7 +922,8 @@ UBOOT_TARGETS := \ UBOOT_CUSTOMIZE_CONFIG := \ --disable TOOLS_KWBIMAGE \ - --disable TOOLS_LIBCRYPTO + --disable TOOLS_LIBCRYPTO \ + --disable TOOLS_MKEFICAPSULE ifdef CONFIG_TARGET_mediatek UBOOT_MAKE_FLAGS += $(UBOOT_IMAGE:.fip=.bin) diff --git a/package/boot/uboot-mediatek/patches/100-02-drivers-mtd-add-support-for-MediaTek-SPI-NAND-flash-.patch b/package/boot/uboot-mediatek/patches/100-02-drivers-mtd-add-support-for-MediaTek-SPI-NAND-flash-.patch index 0e63b1e2d3..e57c88c295 100644 --- a/package/boot/uboot-mediatek/patches/100-02-drivers-mtd-add-support-for-MediaTek-SPI-NAND-flash-.patch +++ b/package/boot/uboot-mediatek/patches/100-02-drivers-mtd-add-support-for-MediaTek-SPI-NAND-flash-.patch @@ -38,7 +38,7 @@ Signed-off-by: Weijie Gao --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig -@@ -238,6 +238,8 @@ config SYS_MAX_FLASH_BANKS_DETECT +@@ -246,6 +246,8 @@ config SYS_MAX_FLASH_BANKS_DETECT to reduce the effective number of flash bank, between 0 and CONFIG_SYS_MAX_FLASH_BANKS @@ -49,7 +49,7 @@ Signed-off-by: Weijie Gao config SYS_NAND_MAX_OOBFREE --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile -@@ -39,3 +39,5 @@ obj-$(CONFIG_$(SPL_TPL_)SPI_FLASH_SUPPOR +@@ -40,3 +40,5 @@ obj-$(CONFIG_$(SPL_TPL_)SPI_FLASH_SUPPOR obj-$(CONFIG_SPL_UBI) += ubispl/ endif @@ -1313,7 +1313,7 @@ Signed-off-by: Weijie Gao + * Author: Weijie Gao + */ + -+#include ++#include +#include +#include +#include @@ -1896,7 +1896,7 @@ Signed-off-by: Weijie Gao +#ifndef _MTK_SNAND_OS_H_ +#define _MTK_SNAND_OS_H_ + -+#include ++#include +#include +#include +#include diff --git a/package/boot/uboot-mediatek/patches/100-03-mtd-mtk-snand-add-support-for-SPL.patch b/package/boot/uboot-mediatek/patches/100-03-mtd-mtk-snand-add-support-for-SPL.patch index 3d7c4a9bf6..27b56f7bd3 100644 --- a/package/boot/uboot-mediatek/patches/100-03-mtd-mtk-snand-add-support-for-SPL.patch +++ b/package/boot/uboot-mediatek/patches/100-03-mtd-mtk-snand-add-support-for-SPL.patch @@ -47,7 +47,7 @@ Signed-off-by: Weijie Gao + * Author: Weijie Gao + */ + -+#include ++#include +#include +#include +#include diff --git a/package/boot/uboot-mediatek/patches/100-04-env-add-support-for-generic-MTD-device.patch b/package/boot/uboot-mediatek/patches/100-04-env-add-support-for-generic-MTD-device.patch index 2f070005d6..8f0a50bd98 100644 --- a/package/boot/uboot-mediatek/patches/100-04-env-add-support-for-generic-MTD-device.patch +++ b/package/boot/uboot-mediatek/patches/100-04-env-add-support-for-generic-MTD-device.patch @@ -370,7 +370,7 @@ Signed-off-by: Weijie Gao +}; --- a/include/env_internal.h +++ b/include/env_internal.h -@@ -108,6 +108,7 @@ enum env_location { +@@ -107,6 +107,7 @@ enum env_location { ENVL_FAT, ENVL_FLASH, ENVL_MMC, diff --git a/package/boot/uboot-mediatek/patches/100-05-mtd-add-a-new-mtd-device-type-for-NMBM.patch b/package/boot/uboot-mediatek/patches/100-05-mtd-add-a-new-mtd-device-type-for-NMBM.patch index d90ca64704..aa19a11587 100644 --- a/package/boot/uboot-mediatek/patches/100-05-mtd-add-a-new-mtd-device-type-for-NMBM.patch +++ b/package/boot/uboot-mediatek/patches/100-05-mtd-add-a-new-mtd-device-type-for-NMBM.patch @@ -15,7 +15,7 @@ Signed-off-by: Weijie Gao --- a/cmd/mtdparts.c +++ b/cmd/mtdparts.c -@@ -1057,6 +1057,9 @@ int mtd_id_parse(const char *id, const c +@@ -1054,6 +1054,9 @@ int mtd_id_parse(const char *id, const c } else if (strncmp(p, "spi-nand", 8) == 0) { *dev_type = MTD_DEV_TYPE_SPINAND; p += 8; @@ -27,7 +27,7 @@ Signed-off-by: Weijie Gao return 1; --- a/include/jffs2/load_kernel.h +++ b/include/jffs2/load_kernel.h -@@ -16,11 +16,13 @@ +@@ -17,11 +17,13 @@ #define MTD_DEV_TYPE_NAND 0x0002 #define MTD_DEV_TYPE_ONENAND 0x0004 #define MTD_DEV_TYPE_SPINAND 0x0008 diff --git a/package/boot/uboot-mediatek/patches/100-06-mtd-add-core-facility-code-of-NMBM.patch b/package/boot/uboot-mediatek/patches/100-06-mtd-add-core-facility-code-of-NMBM.patch index 997d07867b..30d21b0e49 100644 --- a/package/boot/uboot-mediatek/patches/100-06-mtd-add-core-facility-code-of-NMBM.patch +++ b/package/boot/uboot-mediatek/patches/100-06-mtd-add-core-facility-code-of-NMBM.patch @@ -31,7 +31,7 @@ Signed-off-by: Weijie Gao --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig -@@ -274,6 +274,8 @@ source "drivers/mtd/ubi/Kconfig" +@@ -282,6 +282,8 @@ source "drivers/mtd/ubi/Kconfig" source "drivers/mtd/nvmxip/Kconfig" @@ -42,7 +42,7 @@ Signed-off-by: Weijie Gao endmenu --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile -@@ -41,3 +41,4 @@ obj-$(CONFIG_SPL_UBI) += ubispl/ +@@ -42,3 +42,4 @@ obj-$(CONFIG_SPL_UBI) += ubispl/ endif obj-$(CONFIG_MTK_SPI_NAND) += mtk-snand/ diff --git a/package/boot/uboot-mediatek/patches/100-08-common-board_r-add-support-to-initialize-NMBM-after-.patch b/package/boot/uboot-mediatek/patches/100-08-common-board_r-add-support-to-initialize-NMBM-after-.patch index 6a7912e64a..176b215b52 100644 --- a/package/boot/uboot-mediatek/patches/100-08-common-board_r-add-support-to-initialize-NMBM-after-.patch +++ b/package/boot/uboot-mediatek/patches/100-08-common-board_r-add-support-to-initialize-NMBM-after-.patch @@ -13,7 +13,7 @@ Signed-off-by: Weijie Gao --- a/common/board_r.c +++ b/common/board_r.c -@@ -373,6 +373,20 @@ static int initr_nand(void) +@@ -372,6 +372,20 @@ static int initr_nand(void) } #endif @@ -34,7 +34,7 @@ Signed-off-by: Weijie Gao #if defined(CONFIG_CMD_ONENAND) /* go init the NAND */ static int initr_onenand(void) -@@ -664,6 +678,9 @@ static init_fnc_t init_sequence_r[] = { +@@ -663,6 +677,9 @@ static init_fnc_t init_sequence_r[] = { #ifdef CONFIG_CMD_ONENAND initr_onenand, #endif diff --git a/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch b/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch index cd41581006..f988219b6d 100644 --- a/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch +++ b/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch @@ -15,7 +15,7 @@ Signed-off-by: Weijie Gao --- a/cmd/Kconfig +++ b/cmd/Kconfig -@@ -1450,6 +1450,12 @@ config CMD_NAND_TORTURE +@@ -1465,6 +1465,12 @@ config CMD_NAND_TORTURE endif # CMD_NAND diff --git a/package/boot/uboot-mediatek/patches/100-10-cmd-mtd-add-markbad-subcommand-for-NMBM-testing.patch b/package/boot/uboot-mediatek/patches/100-10-cmd-mtd-add-markbad-subcommand-for-NMBM-testing.patch index 34f7fba960..b2a9235cdb 100644 --- a/package/boot/uboot-mediatek/patches/100-10-cmd-mtd-add-markbad-subcommand-for-NMBM-testing.patch +++ b/package/boot/uboot-mediatek/patches/100-10-cmd-mtd-add-markbad-subcommand-for-NMBM-testing.patch @@ -20,7 +20,7 @@ Signed-off-by: SkyLake.Huang --- a/cmd/mtd.c +++ b/cmd/mtd.c -@@ -722,6 +722,42 @@ out_put_mtd: +@@ -721,6 +721,42 @@ out_put_mtd: return CMD_RET_SUCCESS; } @@ -63,7 +63,7 @@ Signed-off-by: SkyLake.Huang #ifdef CONFIG_AUTO_COMPLETE static int mtd_name_complete(int argc, char *const argv[], char last_char, int maxv, char *cmdv[]) -@@ -769,6 +805,7 @@ U_BOOT_LONGHELP(mtd, +@@ -768,6 +804,7 @@ U_BOOT_LONGHELP(mtd, "\n" "Specific functions:\n" "mtd bad \n" @@ -71,7 +71,7 @@ Signed-off-by: SkyLake.Huang #if CONFIG_IS_ENABLED(CMD_MTD_OTP) "mtd otpread [u|f] \n" "mtd otpwrite \n" -@@ -809,4 +846,6 @@ U_BOOT_CMD_WITH_SUBCMDS(mtd, "MTD utils" +@@ -808,4 +845,6 @@ U_BOOT_CMD_WITH_SUBCMDS(mtd, "MTD utils" U_BOOT_SUBCMD_MKENT_COMPLETE(erase, 4, 0, do_mtd_erase, mtd_name_complete), U_BOOT_SUBCMD_MKENT_COMPLETE(bad, 2, 1, do_mtd_bad, diff --git a/package/boot/uboot-mediatek/patches/100-11-env-add-support-for-NMBM-upper-MTD-layer.patch b/package/boot/uboot-mediatek/patches/100-11-env-add-support-for-NMBM-upper-MTD-layer.patch index 0930ace26a..a5f9586b91 100644 --- a/package/boot/uboot-mediatek/patches/100-11-env-add-support-for-NMBM-upper-MTD-layer.patch +++ b/package/boot/uboot-mediatek/patches/100-11-env-add-support-for-NMBM-upper-MTD-layer.patch @@ -240,7 +240,7 @@ Signed-off-by: Weijie Gao +}; --- a/include/env_internal.h +++ b/include/env_internal.h -@@ -110,6 +110,7 @@ enum env_location { +@@ -109,6 +109,7 @@ enum env_location { ENVL_MMC, ENVL_MTD, ENVL_NAND, diff --git a/package/boot/uboot-mediatek/patches/100-13-cmd-add-a-new-command-for-NAND-flash-debugging.patch b/package/boot/uboot-mediatek/patches/100-13-cmd-add-a-new-command-for-NAND-flash-debugging.patch index 97cb1088a0..c16f63fdb3 100644 --- a/package/boot/uboot-mediatek/patches/100-13-cmd-add-a-new-command-for-NAND-flash-debugging.patch +++ b/package/boot/uboot-mediatek/patches/100-13-cmd-add-a-new-command-for-NAND-flash-debugging.patch @@ -26,7 +26,7 @@ Signed-off-by: Weijie Gao --- a/cmd/Kconfig +++ b/cmd/Kconfig -@@ -1450,6 +1450,14 @@ config CMD_NAND_TORTURE +@@ -1465,6 +1465,14 @@ config CMD_NAND_TORTURE endif # CMD_NAND diff --git a/package/boot/uboot-mediatek/patches/100-14-mtd-spi-nor-add-support-to-read-flash-unique-ID.patch b/package/boot/uboot-mediatek/patches/100-14-mtd-spi-nor-add-support-to-read-flash-unique-ID.patch index 8db02ddf6a..82839033a3 100644 --- a/package/boot/uboot-mediatek/patches/100-14-mtd-spi-nor-add-support-to-read-flash-unique-ID.patch +++ b/package/boot/uboot-mediatek/patches/100-14-mtd-spi-nor-add-support-to-read-flash-unique-ID.patch @@ -13,7 +13,7 @@ Signed-off-by: Weijie Gao --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c -@@ -2908,6 +2908,100 @@ static int spi_nor_init_params(struct sp +@@ -2958,6 +2958,100 @@ static int spi_nor_init_params(struct sp return 0; } @@ -114,7 +114,7 @@ Signed-off-by: Weijie Gao static int spi_nor_hwcaps2cmd(u32 hwcaps, const int table[][2], size_t size) { size_t i; -@@ -4027,6 +4121,7 @@ int spi_nor_scan(struct spi_nor *nor) +@@ -4077,6 +4171,7 @@ int spi_nor_scan(struct spi_nor *nor) nor->write = spi_nor_write_data; nor->read_reg = spi_nor_read_reg; nor->write_reg = spi_nor_write_reg; diff --git a/package/boot/uboot-mediatek/patches/100-16-cmd-bootmenu-add-ability-to-select-item-by-shortkey.patch b/package/boot/uboot-mediatek/patches/100-16-cmd-bootmenu-add-ability-to-select-item-by-shortkey.patch index 701acddd78..4aa4318493 100644 --- a/package/boot/uboot-mediatek/patches/100-16-cmd-bootmenu-add-ability-to-select-item-by-shortkey.patch +++ b/package/boot/uboot-mediatek/patches/100-16-cmd-bootmenu-add-ability-to-select-item-by-shortkey.patch @@ -14,7 +14,7 @@ Signed-off-by: Weijie Gao --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c -@@ -89,6 +89,7 @@ static char *bootmenu_choice_entry(void +@@ -88,6 +88,7 @@ static char *bootmenu_choice_entry(void struct bootmenu_data *menu = data; struct bootmenu_entry *iter; enum bootmenu_key key = BKEY_NONE; @@ -22,7 +22,7 @@ Signed-off-by: Weijie Gao int i; cli_ch_init(cch); -@@ -96,10 +97,10 @@ static char *bootmenu_choice_entry(void +@@ -95,10 +96,10 @@ static char *bootmenu_choice_entry(void while (1) { if (menu->delay >= 0) { /* Autoboot was not stopped */ @@ -35,7 +35,7 @@ Signed-off-by: Weijie Gao } switch (key) { -@@ -113,6 +114,12 @@ static char *bootmenu_choice_entry(void +@@ -112,6 +113,12 @@ static char *bootmenu_choice_entry(void ++menu->active; /* no menu key selected, regenerate menu */ return NULL; @@ -48,7 +48,7 @@ Signed-off-by: Weijie Gao case BKEY_SELECT: iter = menu->first; for (i = 0; i < menu->active; ++i) -@@ -170,6 +177,9 @@ static int prepare_bootmenu_entry(struct +@@ -169,6 +176,9 @@ static int prepare_bootmenu_entry(struct unsigned short int i = *index; struct bootmenu_entry *entry = NULL; struct bootmenu_entry *iter = *current; @@ -58,7 +58,7 @@ Signed-off-by: Weijie Gao while ((option = bootmenu_getoption(i))) { -@@ -184,11 +194,24 @@ static int prepare_bootmenu_entry(struct +@@ -183,11 +193,24 @@ static int prepare_bootmenu_entry(struct if (!entry) return -ENOMEM; @@ -84,7 +84,7 @@ Signed-off-by: Weijie Gao entry->command = strdup(sep + 1); if (!entry->command) { -@@ -334,6 +357,7 @@ static struct bootmenu_data *bootmenu_cr +@@ -333,6 +356,7 @@ static struct bootmenu_data *bootmenu_cr menu->delay = delay; menu->active = 0; menu->first = NULL; @@ -92,7 +92,7 @@ Signed-off-by: Weijie Gao default_str = env_get("bootmenu_default"); if (default_str) -@@ -369,9 +393,9 @@ static struct bootmenu_data *bootmenu_cr +@@ -368,9 +392,9 @@ static struct bootmenu_data *bootmenu_cr /* Add Quit entry if exiting bootmenu is disabled */ if (!IS_ENABLED(CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE)) @@ -106,7 +106,7 @@ Signed-off-by: Weijie Gao free(entry); --- a/common/menu.c +++ b/common/menu.c -@@ -49,6 +49,33 @@ struct menu { +@@ -48,6 +48,33 @@ struct menu { int item_cnt; }; @@ -140,7 +140,7 @@ Signed-off-by: Weijie Gao /* * An iterator function for menu items. callback will be called for each item * in m, with m, a pointer to the item, and extra being passed to callback. If -@@ -428,7 +455,7 @@ int menu_destroy(struct menu *m) +@@ -426,7 +453,7 @@ int menu_destroy(struct menu *m) } enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, @@ -149,7 +149,7 @@ Signed-off-by: Weijie Gao { enum bootmenu_key key = BKEY_NONE; int i, c; -@@ -463,6 +490,19 @@ enum bootmenu_key bootmenu_autoboot_loop +@@ -461,6 +488,19 @@ enum bootmenu_key bootmenu_autoboot_loop break; default: key = BKEY_NONE; @@ -169,7 +169,7 @@ Signed-off-by: Weijie Gao break; } break; -@@ -483,7 +523,8 @@ enum bootmenu_key bootmenu_autoboot_loop +@@ -481,7 +521,8 @@ enum bootmenu_key bootmenu_autoboot_loop return key; } @@ -179,7 +179,7 @@ Signed-off-by: Weijie Gao { enum bootmenu_key key; -@@ -515,6 +556,20 @@ enum bootmenu_key bootmenu_conv_key(int +@@ -513,6 +554,20 @@ enum bootmenu_key bootmenu_conv_key(int case ' ': key = BKEY_SPACE; break; @@ -200,7 +200,7 @@ Signed-off-by: Weijie Gao default: key = BKEY_NONE; break; -@@ -524,11 +579,16 @@ enum bootmenu_key bootmenu_conv_key(int +@@ -522,11 +577,16 @@ enum bootmenu_key bootmenu_conv_key(int } enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, @@ -218,7 +218,7 @@ Signed-off-by: Weijie Gao c = cli_ch_process(cch, 0); if (!c) { while (!c && !tstc()) { -@@ -542,7 +602,7 @@ enum bootmenu_key bootmenu_loop(struct b +@@ -540,7 +600,7 @@ enum bootmenu_key bootmenu_loop(struct b } } @@ -301,7 +301,7 @@ Signed-off-by: Weijie Gao switch (key) { case BKEY_UP: -@@ -1839,7 +1839,7 @@ char *eficonfig_choice_change_boot_order +@@ -1881,7 +1881,7 @@ char *eficonfig_choice_change_boot_order cli_ch_init(cch); while (1) { @@ -312,7 +312,7 @@ Signed-off-by: Weijie Gao case BKEY_PLUS: --- a/boot/bootflow_menu.c +++ b/boot/bootflow_menu.c -@@ -234,7 +234,7 @@ int bootflow_menu_run(struct bootstd_pri +@@ -240,7 +240,7 @@ int bootflow_menu_run(struct bootstd_pri key = 0; if (ichar) { diff --git a/package/boot/uboot-mediatek/patches/100-17-common-spl-spl_nand-enable-CONFIG_SYS_NAND_U_BOOT_OF.patch b/package/boot/uboot-mediatek/patches/100-17-common-spl-spl_nand-enable-CONFIG_SYS_NAND_U_BOOT_OF.patch index c65a118b89..8501105863 100644 --- a/package/boot/uboot-mediatek/patches/100-17-common-spl-spl_nand-enable-CONFIG_SYS_NAND_U_BOOT_OF.patch +++ b/package/boot/uboot-mediatek/patches/100-17-common-spl-spl_nand-enable-CONFIG_SYS_NAND_U_BOOT_OF.patch @@ -14,7 +14,7 @@ Signed-off-by: Weijie Gao --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c -@@ -19,7 +19,11 @@ +@@ -18,7 +18,11 @@ uint32_t __weak spl_nand_get_uboot_raw_page(void) { diff --git a/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch b/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch index bc5f68cd1e..8c2bcd5437 100644 --- a/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch +++ b/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch @@ -89,7 +89,7 @@ Signed-off-by: Weijie Gao reg = <0x11014000 0x1000>; --- a/arch/arm/mach-mediatek/Kconfig +++ b/arch/arm/mach-mediatek/Kconfig -@@ -147,9 +147,11 @@ config SYS_CONFIG_NAME +@@ -148,9 +148,11 @@ config SYS_CONFIG_NAME config MTK_BROM_HEADER_INFO string diff --git a/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch b/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch index caedea7315..bfeaf07f04 100644 --- a/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch +++ b/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch @@ -18,7 +18,7 @@ Signed-off-by: Weijie Gao --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile -@@ -1225,6 +1225,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ +@@ -1190,6 +1190,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ mt7623n-bananapi-bpi-r2.dtb \ mt7629-rfb.dtb \ mt7981-rfb.dtb \ diff --git a/package/boot/uboot-mediatek/patches/100-21-mtd-spi-nor-add-more-flash-ids.patch b/package/boot/uboot-mediatek/patches/100-21-mtd-spi-nor-add-more-flash-ids.patch index adcaadf654..578b6e62b8 100644 --- a/package/boot/uboot-mediatek/patches/100-21-mtd-spi-nor-add-more-flash-ids.patch +++ b/package/boot/uboot-mediatek/patches/100-21-mtd-spi-nor-add-more-flash-ids.patch @@ -13,7 +13,7 @@ Signed-off-by: Weijie Gao --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c -@@ -698,6 +698,7 @@ static int set_4byte(struct spi_nor *nor +@@ -697,6 +697,7 @@ static int set_4byte(struct spi_nor *nor case SNOR_MFR_ISSI: case SNOR_MFR_MACRONIX: case SNOR_MFR_WINBOND: @@ -23,7 +23,7 @@ Signed-off-by: Weijie Gao --- a/drivers/mtd/spi/spi-nor-ids.c +++ b/drivers/mtd/spi/spi-nor-ids.c -@@ -84,7 +84,8 @@ const struct flash_info spi_nor_ids[] = +@@ -83,7 +83,8 @@ const struct flash_info spi_nor_ids[] = { INFO("en25q32b", 0x1c3016, 0, 64 * 1024, 64, 0) }, { INFO("en25q64", 0x1c3017, 0, 64 * 1024, 128, SECT_4K) }, { INFO("en25q128b", 0x1c3018, 0, 64 * 1024, 256, 0) }, @@ -33,7 +33,7 @@ Signed-off-by: Weijie Gao { INFO("en25s64", 0x1c3817, 0, 64 * 1024, 128, SECT_4K) }, #endif #ifdef CONFIG_SPI_FLASH_GIGADEVICE /* GIGADEVICE */ -@@ -150,6 +151,11 @@ const struct flash_info spi_nor_ids[] = +@@ -149,6 +150,11 @@ const struct flash_info spi_nor_ids[] = {INFO("gd55x02g", 0xc8481C, 0, 64 * 1024, 4096, SECT_4K | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES)}, { @@ -45,7 +45,7 @@ Signed-off-by: Weijie Gao INFO("gd25lq128", 0xc86018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) -@@ -489,6 +495,16 @@ const struct flash_info spi_nor_ids[] = +@@ -490,6 +496,16 @@ const struct flash_info spi_nor_ids[] = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) }, { @@ -62,7 +62,7 @@ Signed-off-by: Weijie Gao INFO("w25q128jw", 0xef8018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) -@@ -548,6 +564,11 @@ const struct flash_info spi_nor_ids[] = +@@ -549,6 +565,11 @@ const struct flash_info spi_nor_ids[] = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) }, { INFO("w25q256", 0xef4019, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, diff --git a/package/boot/uboot-mediatek/patches/100-22-mtd-spi-nand-backport-from-upstream-kernel.patch b/package/boot/uboot-mediatek/patches/100-22-mtd-spi-nand-backport-from-upstream-kernel.patch index ddfb7577ef..aa03c9b3b9 100644 --- a/package/boot/uboot-mediatek/patches/100-22-mtd-spi-nand-backport-from-upstream-kernel.patch +++ b/package/boot/uboot-mediatek/patches/100-22-mtd-spi-nand-backport-from-upstream-kernel.patch @@ -31,7 +31,7 @@ Signed-off-by: Weijie Gao obj-$(CONFIG_MTD_SPI_NAND) += spinand.o --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c -@@ -822,6 +822,7 @@ static const struct nand_ops spinand_ops +@@ -826,6 +826,7 @@ static const struct nand_ops spinand_ops }; static const struct spinand_manufacturer *spinand_manufacturers[] = { diff --git a/package/boot/uboot-mediatek/patches/100-23-mmc-mtk-sd-add-support-to-display-verbose-error-log.patch b/package/boot/uboot-mediatek/patches/100-23-mmc-mtk-sd-add-support-to-display-verbose-error-log.patch index d33ab0b284..7ab2b6d0ce 100644 --- a/package/boot/uboot-mediatek/patches/100-23-mmc-mtk-sd-add-support-to-display-verbose-error-log.patch +++ b/package/boot/uboot-mediatek/patches/100-23-mmc-mtk-sd-add-support-to-display-verbose-error-log.patch @@ -15,7 +15,7 @@ Signed-off-by: Weijie Gao --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig -@@ -855,6 +855,14 @@ config MMC_MTK +@@ -864,6 +864,14 @@ config MMC_MTK This is needed if support for any SD/SDIO/MMC devices is required. If unsure, say N. @@ -42,7 +42,7 @@ Signed-off-by: Weijie Gao +endif --- a/drivers/mmc/mtk-sd.c +++ b/drivers/mmc/mtk-sd.c -@@ -779,18 +779,24 @@ static int msdc_ops_send_cmd(struct udev +@@ -783,18 +783,24 @@ static int msdc_ops_send_cmd(struct udev if (cmd_ret && !(cmd_ret == -EIO && (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK || diff --git a/package/boot/uboot-mediatek/patches/100-24-cmd-ubi-make-volume-find-create-remove-APIs-public.patch b/package/boot/uboot-mediatek/patches/100-24-cmd-ubi-make-volume-find-create-remove-APIs-public.patch index 3362e0e57d..cba34fce3f 100644 --- a/package/boot/uboot-mediatek/patches/100-24-cmd-ubi-make-volume-find-create-remove-APIs-public.patch +++ b/package/boot/uboot-mediatek/patches/100-24-cmd-ubi-make-volume-find-create-remove-APIs-public.patch @@ -14,7 +14,7 @@ Signed-off-by: Weijie Gao --- a/cmd/ubi.c +++ b/cmd/ubi.c -@@ -213,8 +213,8 @@ bad: +@@ -212,8 +212,8 @@ bad: return err; } @@ -25,16 +25,16 @@ Signed-off-by: Weijie Gao { struct ubi_mkvol_req req; int err; -@@ -247,7 +247,7 @@ static int ubi_create_vol(char *volume, +@@ -246,7 +246,7 @@ static int ubi_create_vol(char *volume, return ubi_create_volume(ubi, &req); } -static struct ubi_volume *ubi_find_volume(char *volume) +struct ubi_volume *ubi_find_volume(char *volume) { - struct ubi_volume *vol = NULL; + struct ubi_volume *vol; int i; -@@ -262,7 +262,7 @@ static struct ubi_volume *ubi_find_volum +@@ -261,7 +261,7 @@ static struct ubi_volume *ubi_find_volum return NULL; } @@ -47,8 +47,8 @@ Signed-off-by: Weijie Gao +++ b/include/ubi_uboot.h @@ -50,6 +50,10 @@ extern void ubi_exit(void); extern int ubi_part(char *part_name, const char *vid_header_offset); - extern int ubi_volume_write(char *volume, void *buf, size_t size); - extern int ubi_volume_read(char *volume, char *buf, size_t size); + extern int ubi_volume_write(char *volume, void *buf, loff_t offset, size_t size); + extern int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size); +extern int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id, + bool skipcheck); +extern struct ubi_volume *ubi_find_volume(char *volume); diff --git a/package/boot/uboot-mediatek/patches/100-25-cmd-ubi-allow-creating-volume-with-all-free-spaces.patch b/package/boot/uboot-mediatek/patches/100-25-cmd-ubi-allow-creating-volume-with-all-free-spaces.patch index d023b004f7..e61f5d1119 100644 --- a/package/boot/uboot-mediatek/patches/100-25-cmd-ubi-allow-creating-volume-with-all-free-spaces.patch +++ b/package/boot/uboot-mediatek/patches/100-25-cmd-ubi-allow-creating-volume-with-all-free-spaces.patch @@ -12,7 +12,7 @@ Signed-off-by: Weijie Gao --- a/cmd/ubi.c +++ b/cmd/ubi.c -@@ -226,7 +226,11 @@ int ubi_create_vol(char *volume, int64_t +@@ -225,7 +225,11 @@ int ubi_create_vol(char *volume, int64_t req.vol_id = vol_id; req.alignment = 1; diff --git a/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch b/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch index fb8d15ddf9..afc586ff1c 100644 --- a/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch +++ b/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch @@ -29,7 +29,7 @@ Signed-off-by: Weijie Gao depends on ENV_IS_IN_UBI --- a/env/ubi.c +++ b/env/ubi.c -@@ -106,6 +106,18 @@ static int env_ubi_save(void) +@@ -105,6 +105,18 @@ static int env_ubi_save(void) #endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */ #endif /* CONFIG_CMD_SAVEENV */ @@ -48,7 +48,7 @@ Signed-off-by: Weijie Gao #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT static int env_ubi_load(void) { -@@ -135,6 +147,11 @@ static int env_ubi_load(void) +@@ -134,6 +146,10 @@ static int env_ubi_load(void) return -EIO; } @@ -56,17 +56,16 @@ Signed-off-by: Weijie Gao + env_ubi_volume_create(CONFIG_ENV_UBI_VOLUME); + env_ubi_volume_create(CONFIG_ENV_UBI_VOLUME_REDUND); + } -+ - read1_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)tmp_env1, + read1_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)tmp_env1, 0, CONFIG_ENV_SIZE); if (read1_fail) -@@ -172,6 +189,9 @@ static int env_ubi_load(void) +@@ -171,6 +187,9 @@ static int env_ubi_load(void) return -EIO; } + if (IS_ENABLED(CONFIG_ENV_UBI_VOLUME_CREATE)) + env_ubi_volume_create(CONFIG_ENV_UBI_VOLUME); + - if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, CONFIG_ENV_SIZE)) { + if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, 0, CONFIG_ENV_SIZE)) { printf("\n** Unable to read env from %s:%s **\n", CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME); diff --git a/package/boot/uboot-mediatek/patches/100-29-board-mediatek-wire-up-NMBM-support.patch b/package/boot/uboot-mediatek/patches/100-29-board-mediatek-wire-up-NMBM-support.patch index f22449ae76..aea82d898e 100644 --- a/package/boot/uboot-mediatek/patches/100-29-board-mediatek-wire-up-NMBM-support.patch +++ b/package/boot/uboot-mediatek/patches/100-29-board-mediatek-wire-up-NMBM-support.patch @@ -12,7 +12,7 @@ Subject: [PATCH] board: mediatek: wire-up NMBM support --- a/board/mediatek/mt7622/mt7622_rfb.c +++ b/board/mediatek/mt7622/mt7622_rfb.c -@@ -10,6 +10,11 @@ +@@ -9,6 +9,11 @@ #include #include @@ -24,7 +24,7 @@ Subject: [PATCH] board: mediatek: wire-up NMBM support DECLARE_GLOBAL_DATA_PTR; int board_init(void) -@@ -23,3 +28,36 @@ int board_late_init(void) +@@ -22,3 +27,36 @@ int board_late_init(void) env_relocate(); return 0; } @@ -64,7 +64,7 @@ Subject: [PATCH] board: mediatek: wire-up NMBM support --- a/board/mediatek/mt7629/mt7629_rfb.c +++ b/board/mediatek/mt7629/mt7629_rfb.c @@ -6,6 +6,11 @@ - #include + #include #include +#include @@ -114,11 +114,10 @@ Subject: [PATCH] board: mediatek: wire-up NMBM support +} --- a/board/mediatek/mt7981/mt7981_rfb.c +++ b/board/mediatek/mt7981/mt7981_rfb.c -@@ -4,7 +4,58 @@ +@@ -4,7 +4,57 @@ * Author: Sam Shih */ -+#include +#include +#include +#include @@ -175,11 +174,10 @@ Subject: [PATCH] board: mediatek: wire-up NMBM support +} --- a/board/mediatek/mt7986/mt7986_rfb.c +++ b/board/mediatek/mt7986/mt7986_rfb.c -@@ -4,7 +4,60 @@ +@@ -4,7 +4,59 @@ * Author: Sam Shih */ -+#include +#include +#include +#include diff --git a/package/boot/uboot-mediatek/patches/160-net-phy-add-support-for-Airoha-ethernet-PHY-driver.patch b/package/boot/uboot-mediatek/patches/160-net-phy-add-support-for-Airoha-ethernet-PHY-driver.patch index f8e8659952..2a71a4eb92 100644 --- a/package/boot/uboot-mediatek/patches/160-net-phy-add-support-for-Airoha-ethernet-PHY-driver.patch +++ b/package/boot/uboot-mediatek/patches/160-net-phy-add-support-for-Airoha-ethernet-PHY-driver.patch @@ -58,7 +58,7 @@ Signed-off-by: Weijie Gao --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig -@@ -77,6 +77,37 @@ config PHY_ADIN +@@ -83,6 +83,37 @@ config PHY_ADIN help Add support for configuring RGMII on Analog Devices ADIN PHYs. @@ -122,7 +122,7 @@ Signed-off-by: Weijie Gao + +/* INCLUDE FILE DECLARATIONS + */ -+#include ++#include +#include +#include +#include @@ -1028,7 +1028,7 @@ Signed-off-by: Weijie Gao + +/* INCLUDE FILE DECLARATIONS +*/ -+#include ++#include +#include +#include +#include @@ -1421,7 +1421,7 @@ Signed-off-by: Weijie Gao + } + +#ifdef CONFIG_PHY_AIROHA_FW_IN_UBI -+ ret = ubi_volume_read("en8811h-fw", firmware_buf, EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE); ++ ret = ubi_volume_read("en8811h-fw", firmware_buf, 0, EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE); + if (ret) { + printf("[Airoha] read firmware from UBI failed.\n"); + free(firmware_buf); @@ -1909,7 +1909,7 @@ Signed-off-by: Weijie Gao + --- a/drivers/net/eth-phy-uclass.c +++ b/drivers/net/eth-phy-uclass.c -@@ -155,7 +155,7 @@ static int eth_phy_of_to_plat(struct ude +@@ -154,7 +154,7 @@ static int eth_phy_of_to_plat(struct ude return 0; } diff --git a/package/boot/uboot-mediatek/patches/200-cmd-add-imsz-and-imszb.patch b/package/boot/uboot-mediatek/patches/200-cmd-add-imsz-and-imszb.patch index d10391e8c6..81c24543e2 100644 --- a/package/boot/uboot-mediatek/patches/200-cmd-add-imsz-and-imszb.patch +++ b/package/boot/uboot-mediatek/patches/200-cmd-add-imsz-and-imszb.patch @@ -1,6 +1,6 @@ --- a/cmd/bootm.c +++ b/cmd/bootm.c -@@ -262,6 +262,67 @@ U_BOOT_CMD( +@@ -260,6 +260,67 @@ U_BOOT_CMD( /* iminfo - print header info for a requested image */ /*******************************************************************/ #if defined(CONFIG_CMD_IMI) @@ -70,7 +70,7 @@ { --- a/boot/image-fit.c +++ b/boot/image-fit.c -@@ -2051,6 +2051,47 @@ static const char *fit_get_image_type_pr +@@ -2046,6 +2046,47 @@ static const char *fit_get_image_type_pr return "unknown"; } @@ -120,7 +120,7 @@ int arch, int ph_type, int bootstage_id, --- a/include/image.h +++ b/include/image.h -@@ -1123,6 +1123,7 @@ int fit_parse_subimage(const char *spec, +@@ -1124,6 +1124,7 @@ int fit_parse_subimage(const char *spec, ulong *addr, const char **image_name); int fit_get_subimage_count(const void *fit, int images_noffset); diff --git a/package/boot/uboot-mediatek/patches/211-cmd-bootmenu-custom-title.patch b/package/boot/uboot-mediatek/patches/211-cmd-bootmenu-custom-title.patch index a99b77be08..76ff745e93 100644 --- a/package/boot/uboot-mediatek/patches/211-cmd-bootmenu-custom-title.patch +++ b/package/boot/uboot-mediatek/patches/211-cmd-bootmenu-custom-title.patch @@ -1,6 +1,6 @@ --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c -@@ -452,7 +452,11 @@ static void menu_display_statusline(stru +@@ -451,7 +451,11 @@ static void menu_display_statusline(stru printf(ANSI_CURSOR_POSITION, 1, 1); puts(ANSI_CLEAR_LINE); printf(ANSI_CURSOR_POSITION, 2, 3); @@ -13,7 +13,7 @@ puts(ANSI_CLEAR_LINE_TO_END); printf(ANSI_CURSOR_POSITION, 3, 1); puts(ANSI_CLEAR_LINE); -@@ -537,6 +541,7 @@ static enum bootmenu_ret bootmenu_show(i +@@ -536,6 +540,7 @@ static enum bootmenu_ret bootmenu_show(i return BOOTMENU_RET_FAIL; } diff --git a/package/boot/uboot-mediatek/patches/220-cmd-env-readmem.patch b/package/boot/uboot-mediatek/patches/220-cmd-env-readmem.patch index 6f5f5539ab..58f7d316a6 100644 --- a/package/boot/uboot-mediatek/patches/220-cmd-env-readmem.patch +++ b/package/boot/uboot-mediatek/patches/220-cmd-env-readmem.patch @@ -1,6 +1,6 @@ --- a/cmd/Kconfig +++ b/cmd/Kconfig -@@ -676,6 +676,12 @@ config CMD_ENV_EXISTS +@@ -683,6 +683,12 @@ config CMD_ENV_EXISTS Check if a variable is defined in the environment for use in shell scripting. diff --git a/package/boot/uboot-mediatek/patches/250-fix-mmc-erase-timeout.patch b/package/boot/uboot-mediatek/patches/250-fix-mmc-erase-timeout.patch index fd5fdd814b..e03b212a74 100644 --- a/package/boot/uboot-mediatek/patches/250-fix-mmc-erase-timeout.patch +++ b/package/boot/uboot-mediatek/patches/250-fix-mmc-erase-timeout.patch @@ -1,6 +1,6 @@ --- a/drivers/mmc/mmc_write.c +++ b/drivers/mmc/mmc_write.c -@@ -80,7 +80,7 @@ ulong mmc_berase(struct blk_desc *block_ +@@ -79,7 +79,7 @@ ulong mmc_berase(struct blk_desc *block_ u32 start_rem, blkcnt_rem, erase_args = 0; struct mmc *mmc = find_mmc_device(dev_num); lbaint_t blk = 0, blk_r = 0; diff --git a/package/boot/uboot-mediatek/patches/280-image-fdt-save-name-of-FIT-configuration-in-chosen-node.patch b/package/boot/uboot-mediatek/patches/280-image-fdt-save-name-of-FIT-configuration-in-chosen-node.patch index 6755f614a9..419ee4adb8 100644 --- a/package/boot/uboot-mediatek/patches/280-image-fdt-save-name-of-FIT-configuration-in-chosen-node.patch +++ b/package/boot/uboot-mediatek/patches/280-image-fdt-save-name-of-FIT-configuration-in-chosen-node.patch @@ -16,7 +16,7 @@ Reviewed-by: Tom Rini --- a/boot/image-fdt.c +++ b/boot/image-fdt.c -@@ -618,6 +618,12 @@ int image_setup_libfdt(struct bootm_head +@@ -617,6 +617,12 @@ int image_setup_libfdt(struct bootm_head images->fit_uname_cfg, strlen(images->fit_uname_cfg) + 1, 1); diff --git a/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch b/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch index 86c48badda..5fc3d0a344 100644 --- a/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch +++ b/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch @@ -2,7 +2,7 @@ +++ b/board/mediatek/mt7623/mt7623_rfb.c @@ -5,6 +5,7 @@ - #include + #include #include +#include #include diff --git a/package/boot/uboot-mediatek/patches/301-mt7622-generic-reset-button-ignore-env.patch b/package/boot/uboot-mediatek/patches/301-mt7622-generic-reset-button-ignore-env.patch index 47c92a85bd..57a119bd39 100644 --- a/package/boot/uboot-mediatek/patches/301-mt7622-generic-reset-button-ignore-env.patch +++ b/package/boot/uboot-mediatek/patches/301-mt7622-generic-reset-button-ignore-env.patch @@ -1,8 +1,8 @@ --- a/board/mediatek/mt7622/mt7622_rfb.c +++ b/board/mediatek/mt7622/mt7622_rfb.c -@@ -6,9 +6,16 @@ +@@ -5,9 +5,16 @@ + */ - #include #include +#include +#include @@ -17,7 +17,7 @@ #include #include -@@ -24,7 +31,22 @@ int board_init(void) +@@ -23,7 +30,22 @@ int board_init(void) int board_late_init(void) { @@ -43,7 +43,7 @@ } --- a/arch/arm/mach-mediatek/Kconfig +++ b/arch/arm/mach-mediatek/Kconfig -@@ -154,4 +154,11 @@ config MTK_BROM_HEADER_INFO +@@ -155,4 +155,11 @@ config MTK_BROM_HEADER_INFO source "board/mediatek/mt7629/Kconfig" diff --git a/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch b/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch index b8d89058a2..a6e4229dd5 100644 --- a/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch +++ b/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch @@ -3,7 +3,7 @@ @@ -4,9 +4,18 @@ */ - #include + #include +#include +#include +#include diff --git a/package/boot/uboot-mediatek/patches/303-mt7986-generic-reset-button-ignore-env.patch b/package/boot/uboot-mediatek/patches/303-mt7986-generic-reset-button-ignore-env.patch index 45290149f3..01b4b52952 100644 --- a/package/boot/uboot-mediatek/patches/303-mt7986-generic-reset-button-ignore-env.patch +++ b/package/boot/uboot-mediatek/patches/303-mt7986-generic-reset-button-ignore-env.patch @@ -1,8 +1,8 @@ --- a/board/mediatek/mt7986/mt7986_rfb.c +++ b/board/mediatek/mt7986/mt7986_rfb.c -@@ -6,9 +6,16 @@ +@@ -5,9 +5,16 @@ + */ - #include #include +#include +#include @@ -17,7 +17,7 @@ #include #include -@@ -24,7 +31,22 @@ int board_init(void) +@@ -23,7 +30,22 @@ int board_init(void) int board_late_init(void) { diff --git a/package/boot/uboot-mediatek/patches/304-mt7981-generic-reset-button-ignore-env.patch b/package/boot/uboot-mediatek/patches/304-mt7981-generic-reset-button-ignore-env.patch index fc44334982..b3ac2aa27f 100644 --- a/package/boot/uboot-mediatek/patches/304-mt7981-generic-reset-button-ignore-env.patch +++ b/package/boot/uboot-mediatek/patches/304-mt7981-generic-reset-button-ignore-env.patch @@ -1,8 +1,8 @@ --- a/board/mediatek/mt7981/mt7981_rfb.c +++ b/board/mediatek/mt7981/mt7981_rfb.c -@@ -6,9 +6,16 @@ +@@ -5,9 +5,16 @@ + */ - #include #include +#include +#include @@ -17,7 +17,7 @@ #include #include -@@ -24,7 +31,22 @@ int board_init(void) +@@ -23,7 +30,22 @@ int board_init(void) int board_late_init(void) { diff --git a/package/boot/uboot-mediatek/patches/305-mt7988-generic-reset-button-ignore-env.patch b/package/boot/uboot-mediatek/patches/305-mt7988-generic-reset-button-ignore-env.patch index 2bbc5c1005..3f239c984a 100644 --- a/package/boot/uboot-mediatek/patches/305-mt7988-generic-reset-button-ignore-env.patch +++ b/package/boot/uboot-mediatek/patches/305-mt7988-generic-reset-button-ignore-env.patch @@ -1,10 +1,9 @@ --- a/board/mediatek/mt7988/mt7988_rfb.c +++ b/board/mediatek/mt7988/mt7988_rfb.c -@@ -4,7 +4,43 @@ +@@ -4,7 +4,42 @@ * Author: Sam Shih */ -+#include +#include +#include +#include diff --git a/package/boot/uboot-mediatek/patches/310-mt7988-select-rootdisk.patch b/package/boot/uboot-mediatek/patches/310-mt7988-select-rootdisk.patch index 28d7e0a3f6..308108e621 100644 --- a/package/boot/uboot-mediatek/patches/310-mt7988-select-rootdisk.patch +++ b/package/boot/uboot-mediatek/patches/310-mt7988-select-rootdisk.patch @@ -1,6 +1,6 @@ --- a/board/mediatek/mt7988/mt7988_rfb.c +++ b/board/mediatek/mt7988/mt7988_rfb.c -@@ -11,7 +11,9 @@ +@@ -10,7 +10,9 @@ #include #include #include @@ -10,7 +10,7 @@ #ifndef CONFIG_RESET_BUTTON_LABEL #define CONFIG_RESET_BUTTON_LABEL "reset" -@@ -44,3 +46,54 @@ int board_late_init(void) +@@ -43,3 +45,54 @@ int board_late_init(void) env_relocate(); return 0; } diff --git a/package/boot/uboot-mediatek/patches/311-mt7986-select-rootdisk.patch b/package/boot/uboot-mediatek/patches/311-mt7986-select-rootdisk.patch index 3312162765..3588dc2a88 100644 --- a/package/boot/uboot-mediatek/patches/311-mt7986-select-rootdisk.patch +++ b/package/boot/uboot-mediatek/patches/311-mt7986-select-rootdisk.patch @@ -1,6 +1,6 @@ --- a/board/mediatek/mt7986/mt7986_rfb.c +++ b/board/mediatek/mt7986/mt7986_rfb.c -@@ -11,7 +11,9 @@ +@@ -10,7 +10,9 @@ #include #include #include @@ -10,7 +10,7 @@ #ifndef CONFIG_RESET_BUTTON_LABEL #define CONFIG_RESET_BUTTON_LABEL "reset" -@@ -83,3 +85,54 @@ int board_nmbm_init(void) +@@ -82,3 +84,54 @@ int board_nmbm_init(void) return 0; } diff --git a/package/boot/uboot-mediatek/patches/312-mt7622-select-rootdisk.patch b/package/boot/uboot-mediatek/patches/312-mt7622-select-rootdisk.patch index 70cbf6b463..44caf8465c 100644 --- a/package/boot/uboot-mediatek/patches/312-mt7622-select-rootdisk.patch +++ b/package/boot/uboot-mediatek/patches/312-mt7622-select-rootdisk.patch @@ -1,6 +1,6 @@ --- a/board/mediatek/mt7622/mt7622_rfb.c +++ b/board/mediatek/mt7622/mt7622_rfb.c -@@ -11,7 +11,9 @@ +@@ -10,7 +10,9 @@ #include #include #include @@ -10,7 +10,7 @@ #ifndef CONFIG_RESET_BUTTON_LABEL #define CONFIG_RESET_BUTTON_LABEL "reset" -@@ -22,10 +24,43 @@ +@@ -21,10 +23,43 @@ #include #include @@ -54,7 +54,7 @@ return 0; } -@@ -83,3 +118,84 @@ int board_nmbm_init(void) +@@ -82,3 +117,84 @@ int board_nmbm_init(void) return 0; } diff --git a/package/boot/uboot-mediatek/patches/314-mt7981-select-rootdisk.patch b/package/boot/uboot-mediatek/patches/314-mt7981-select-rootdisk.patch index 05b620a276..8c13a70468 100644 --- a/package/boot/uboot-mediatek/patches/314-mt7981-select-rootdisk.patch +++ b/package/boot/uboot-mediatek/patches/314-mt7981-select-rootdisk.patch @@ -1,6 +1,6 @@ --- a/board/mediatek/mt7981/mt7981_rfb.c +++ b/board/mediatek/mt7981/mt7981_rfb.c -@@ -11,7 +11,9 @@ +@@ -10,7 +10,9 @@ #include #include #include @@ -10,7 +10,7 @@ #ifndef CONFIG_RESET_BUTTON_LABEL #define CONFIG_RESET_BUTTON_LABEL "reset" -@@ -81,3 +83,54 @@ int board_nmbm_init(void) +@@ -80,3 +82,54 @@ int board_nmbm_init(void) return 0; } @@ -81,9 +81,9 @@ +CONFIG_OF_SYSTEM_SETUP=y --- a/configs/mt7981_rfb_defconfig +++ b/configs/mt7981_rfb_defconfig -@@ -134,3 +134,4 @@ CONFIG_DM_SPI=y - CONFIG_MTK_SPIM=y +@@ -135,3 +135,4 @@ CONFIG_MTK_SPIM=y CONFIG_HEXDUMP=y + # CONFIG_EFI_LOADER is not set CONFIG_LMB_MAX_REGIONS=64 +CONFIG_OF_SYSTEM_SETUP=y --- a/configs/mt7981_sd_rfb_defconfig diff --git a/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch b/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch index ae3d1105fb..72db99a4d0 100644 --- a/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch +++ b/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch @@ -332,7 +332,7 @@ +}; --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile -@@ -1222,6 +1222,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ +@@ -1187,6 +1187,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ mt7622-rfb.dtb \ mt7623a-unielec-u7623-02-emmc.dtb \ mt7622-bananapi-bpi-r64.dtb \ diff --git a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch index eeb96b8d75..04463aba92 100644 --- a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch +++ b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch @@ -739,7 +739,7 @@ +}; --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile -@@ -1223,6 +1223,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ +@@ -1188,6 +1188,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ mt7623a-unielec-u7623-02-emmc.dtb \ mt7622-bananapi-bpi-r64.dtb \ mt7622-linksys-e8450-ubi.dtb \ @@ -917,7 +917,7 @@ DECLARE_GLOBAL_DATA_PTR; -@@ -397,6 +398,20 @@ static int initr_onenand(void) +@@ -396,6 +397,20 @@ static int initr_onenand(void) } #endif @@ -938,7 +938,7 @@ #ifdef CONFIG_MMC static int initr_mmc(void) { -@@ -681,6 +696,9 @@ static init_fnc_t init_sequence_r[] = { +@@ -680,6 +695,9 @@ static init_fnc_t init_sequence_r[] = { #ifdef CONFIG_NMBM_MTD initr_nmbm, #endif diff --git a/package/boot/uboot-mediatek/patches/442-add-bpi-r3-mini.patch b/package/boot/uboot-mediatek/patches/442-add-bpi-r3-mini.patch index da7f2b21c4..611636a574 100644 --- a/package/boot/uboot-mediatek/patches/442-add-bpi-r3-mini.patch +++ b/package/boot/uboot-mediatek/patches/442-add-bpi-r3-mini.patch @@ -149,7 +149,7 @@ +CONFIG_LMB_MAX_REGIONS=64 --- /dev/null +++ b/configs/mt7986a_bpi-r3-mini-snand_defconfig -@@ -0,0 +1,139 @@ +@@ -0,0 +1,140 @@ +CONFIG_ARM=y +CONFIG_SYS_HAS_NONCACHED_MEMORY=y +CONFIG_POSITION_INDEPENDENT=y @@ -256,6 +256,7 @@ +CONFIG_MTD_UBI_FASTMAP=y +CONFIG_PHY_AIROHA=y +CONFIG_PHY_AIROHA_EN8811H=y ++CONFIG_PHY_AIROHA_FW_IN_UBI=y +CONFIG_PHY_ETHERNET_ID=y +CONFIG_PHY_FIXED=y +CONFIG_DM_MDIO=y diff --git a/package/boot/uboot-mediatek/patches/452-add-xiaomi-redmi-ax6s.patch b/package/boot/uboot-mediatek/patches/452-add-xiaomi-redmi-ax6s.patch index 0dca9a84b1..b4d9b4dc76 100644 --- a/package/boot/uboot-mediatek/patches/452-add-xiaomi-redmi-ax6s.patch +++ b/package/boot/uboot-mediatek/patches/452-add-xiaomi-redmi-ax6s.patch @@ -15,7 +15,7 @@ Subject: [PATCH] add xiaomi redmi ax6s --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile -@@ -1225,6 +1225,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ +@@ -1190,6 +1190,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ mt7622-linksys-e8450-ubi.dtb \ mt7622-ubnt-unifi-6-lr.dtb \ mt7622-ubnt-unifi-6-lr-v3.dtb \ diff --git a/package/boot/uboot-mediatek/patches/454-add-glinet-x3000.patch b/package/boot/uboot-mediatek/patches/454-add-glinet-x3000.patch index 0cad80ed5a..069a240d49 100644 --- a/package/boot/uboot-mediatek/patches/454-add-glinet-x3000.patch +++ b/package/boot/uboot-mediatek/patches/454-add-glinet-x3000.patch @@ -1,6 +1,3 @@ -diff --git a/arch/arm/dts/mt7981-glinet-gl-x3000.dts b/arch/arm/dts/mt7981-glinet-gl-x3000.dts -new file mode 100644 -index 0000000..911a702 --- /dev/null +++ b/arch/arm/dts/mt7981-glinet-gl-x3000.dts @@ -0,0 +1,144 @@ @@ -148,9 +145,6 @@ index 0000000..911a702 +&uart0 { + status = "okay"; +}; -diff --git a/configs/mt7981_glinet_gl-x3000_defconfig b/configs/mt7981_glinet_gl-x3000_defconfig -new file mode 100644 -index 0000000..96ad96f --- /dev/null +++ b/configs/mt7981_glinet_gl-x3000_defconfig @@ -0,0 +1,100 @@ @@ -254,9 +248,6 @@ index 0000000..96ad96f +# CONFIG_EFI_LOADER is not set +CONFIG_LMB_MAX_REGIONS=64 +# CONFIG_TOOLS_LIBCRYPTO is not set -diff --git a/glinet_gl-x3000_env b/glinet_gl-x3000_env -new file mode 100644 -index 0000000..e624e41 --- /dev/null +++ b/glinet_gl-x3000_env @@ -0,0 +1,26 @@ diff --git a/package/devel/gdb/Makefile b/package/devel/gdb/Makefile index cf897b79f2..366746be87 100644 --- a/package/devel/gdb/Makefile +++ b/package/devel/gdb/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gdb -PKG_VERSION:=14.1 +PKG_VERSION:=15.2 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/gdb -PKG_HASH:=d66df51276143451fcbff464cc8723d68f1e9df45a6a2d5635a54e71643edb80 +PKG_HASH:=83350ccd35b5b5a0cba6b334c41294ea968158c573940904f00b92f76345314d PKG_BUILD_PARALLEL:=1 PKG_INSTALL:=1 diff --git a/package/devel/gdb/patches/001-gdb-pr14523-mips-signal-number.patch b/package/devel/gdb/patches/001-gdb-pr14523-mips-signal-number.patch deleted file mode 100644 index b8e7b10fc9..0000000000 --- a/package/devel/gdb/patches/001-gdb-pr14523-mips-signal-number.patch +++ /dev/null @@ -1,16 +0,0 @@ -See http://sourceware.org/bugzilla/show_bug.cgi?id=14523 - ---- a/gdbsupport/signals.cc -+++ b/gdbsupport/signals.cc -@@ -348,6 +348,11 @@ gdb_signal_from_host (int hostsig) - else if (64 <= hostsig && hostsig <= 127) - return (enum gdb_signal) - (hostsig - 64 + (int) GDB_SIGNAL_REALTIME_64); -+ else if (hostsig == 128) -+ /* Some platforms, such as Linux MIPS, have NSIG == 128, in which case -+ signal 128 is the highest realtime signal. There is no constant for -+ that though. */ -+ return GDB_SIGNAL_UNKNOWN; - else - error (_("GDB bug: target.c (gdb_signal_from_host): " - "unrecognized real-time signal")); diff --git a/package/devel/gdb/patches/110-shared_libgcc.patch b/package/devel/gdb/patches/110-shared_libgcc.patch index 1a02ad1160..d9dcafe0e0 100644 --- a/package/devel/gdb/patches/110-shared_libgcc.patch +++ b/package/devel/gdb/patches/110-shared_libgcc.patch @@ -1,6 +1,6 @@ --- a/configure.ac +++ b/configure.ac -@@ -1400,13 +1400,13 @@ if test -z "$LD"; then +@@ -1401,13 +1401,13 @@ if test -z "$LD"; then fi fi @@ -17,7 +17,7 @@ AC_LANG_PUSH(C++) AC_LINK_IFELSE([AC_LANG_SOURCE([ #if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) -@@ -1836,7 +1836,7 @@ AC_ARG_WITH(stage1-ldflags, +@@ -1837,7 +1837,7 @@ AC_ARG_WITH(stage1-ldflags, # trust that they are doing what they want. if test "$with_static_standard_libraries" = yes -a "$stage1_libs" = "" \ -a "$have_static_libs" = yes; then @@ -26,18 +26,18 @@ fi]) AC_SUBST(stage1_ldflags) -@@ -1865,7 +1865,7 @@ AC_ARG_WITH(boot-ldflags, +@@ -1866,7 +1866,7 @@ AC_ARG_WITH(boot-ldflags, # statically. But if the user explicitly specified the libraries to # use, trust that they are doing what they want. if test "$poststage1_libs" = ""; then - poststage1_ldflags="-static-libstdc++ -static-libgcc" + poststage1_ldflags="-static-libstdc++" fi]) - AC_SUBST(poststage1_ldflags) - + case $target in + *-darwin2* | *-darwin1[[56789]]*) --- a/configure +++ b/configure -@@ -5413,14 +5413,14 @@ if test -z "$LD"; then +@@ -5414,14 +5414,14 @@ if test -z "$LD"; then fi fi @@ -56,7 +56,7 @@ ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -@@ -8464,7 +8464,7 @@ else +@@ -8465,7 +8465,7 @@ else # trust that they are doing what they want. if test "$with_static_standard_libraries" = yes -a "$stage1_libs" = "" \ -a "$have_static_libs" = yes; then @@ -65,7 +65,7 @@ fi fi -@@ -8500,7 +8500,7 @@ else +@@ -8501,7 +8501,7 @@ else # statically. But if the user explicitly specified the libraries to # use, trust that they are doing what they want. if test "$poststage1_libs" = ""; then diff --git a/package/devel/gdb/patches/120-sigprocmask-invalid-call.patch b/package/devel/gdb/patches/120-sigprocmask-invalid-call.patch index 1ac8f5f2ce..0796c34c76 100644 --- a/package/devel/gdb/patches/120-sigprocmask-invalid-call.patch +++ b/package/devel/gdb/patches/120-sigprocmask-invalid-call.patch @@ -27,7 +27,7 @@ gdb/ChangeLog: --- a/gdbsupport/signals-state-save-restore.cc +++ b/gdbsupport/signals-state-save-restore.cc -@@ -38,7 +38,7 @@ save_original_signals_state (bool quiet) +@@ -37,7 +37,7 @@ save_original_signals_state (bool quiet) int i; int res; diff --git a/package/devel/gdb/patches/130-gdb-ctrl-c.patch b/package/devel/gdb/patches/130-gdb-ctrl-c.patch deleted file mode 100644 index 5272b7e969..0000000000 --- a/package/devel/gdb/patches/130-gdb-ctrl-c.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 63df98fa78c8a6e12b40ebdc5c155838d2bf8b5f Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Thu, 29 Nov 2018 18:00:23 -0800 -Subject: [PATCH 11/11] gdbserver ctrl-c handling - -This problem was created by the upstream commit 78708b7c8c -After applying the commit, it will send SIGINT to the process -group(-signal_pid). -But if we use gdbserver send SIGINT, and the attached process is not a -process -group leader, then the "kill (-signal_pid, SIGINT)" returns error and -fails to -interrupt the attached process. - -Upstream-Status: Submitted -[https://sourceware.org/bugzilla/show_bug.cgi?id=18945] - -Author: Josh Gao -Signed-off-by: Zhixiong Chi -Signed-off-by: Khem Raj ---- - gdbserver/linux-low.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/gdbserver/linux-low.cc -+++ b/gdbserver/linux-low.cc -@@ -5481,7 +5481,7 @@ linux_process_target::request_interrupt - { - /* Send a SIGINT to the process group. This acts just like the user - typed a ^C on the controlling terminal. */ -- int res = ::kill (-signal_pid, SIGINT); -+ int res = ::kill (signal_pid, SIGINT); - if (res == -1) - warning (_("Sending SIGINT to process group of pid %ld failed: %s"), - signal_pid, safe_strerror (errno)); diff --git a/package/devel/gdb/patches/140-sgidefs.patch b/package/devel/gdb/patches/140-sgidefs.patch index 05b30f5242..1753e9bb85 100644 --- a/package/devel/gdb/patches/140-sgidefs.patch +++ b/package/devel/gdb/patches/140-sgidefs.patch @@ -19,7 +19,7 @@ Signed-off-by: Andre McCurdy --- a/gdb/mips-linux-nat.c +++ b/gdb/mips-linux-nat.c -@@ -31,7 +31,7 @@ +@@ -30,7 +30,7 @@ #include "gdb_proc_service.h" #include "gregset.h" diff --git a/package/devel/gdb/patches/150-mips64.patch b/package/devel/gdb/patches/150-mips64.patch index 65418fd290..41c267bcf6 100644 --- a/package/devel/gdb/patches/150-mips64.patch +++ b/package/devel/gdb/patches/150-mips64.patch @@ -18,7 +18,7 @@ Upstream-Status: Pending --- a/gdb/mips-linux-nat.c +++ b/gdb/mips-linux-nat.c -@@ -42,6 +42,11 @@ +@@ -41,6 +41,11 @@ #define PTRACE_GET_THREAD_AREA 25 #endif diff --git a/package/firmware/wireless-regdb/Makefile b/package/firmware/wireless-regdb/Makefile index 4cce267f61..7d4cf63c47 100644 --- a/package/firmware/wireless-regdb/Makefile +++ b/package/firmware/wireless-regdb/Makefile @@ -1,14 +1,14 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wireless-regdb -PKG_VERSION:=2024.07.04 +PKG_VERSION:=2024.10.07 PKG_RELEASE:=1 PKG_LICENSE:=ISC PKG_LICENSE_FILES:=LICENSE PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/software/network/wireless-regdb/ -PKG_HASH:=9832a14e1be24abff7be30dee3c9a1afb5fdfcf475a0d91aafef039f8d85f5eb +PKG_HASH:=f76f2bd79a653e9f9dd50548d99d03a4a4eb157da056dfd5892f403ec28fb3d5 PKG_MAINTAINER:=Felix Fietkau diff --git a/package/kernel/linux/modules/netdevices.mk b/package/kernel/linux/modules/netdevices.mk index a2ecde666f..d5966e7b3d 100644 --- a/package/kernel/linux/modules/netdevices.mk +++ b/package/kernel/linux/modules/netdevices.mk @@ -560,6 +560,7 @@ define KernelPackage/dsa-mv88e6xxx TITLE:=Marvell MV88E6XXX DSA Switch DEPENDS:=+kmod-dsa +kmod-ptp +kmod-phy-marvell +kmod-dsa-tag-dsa KCONFIG:=CONFIG_NET_DSA_MV88E6XXX \ + CONFIG_NET_DSA_MV88E6XXX_LEDS=y \ CONFIG_NET_DSA_MV88E6XXX_PTP=y FILES:=$(LINUX_DIR)/drivers/net/dsa/mv88e6xxx/mv88e6xxx.ko AUTOLOAD:=$(call AutoLoad,41,mv88e6xxx,1) diff --git a/package/network/services/ppp/Makefile b/package/network/services/ppp/Makefile index 10616b2060..f9ad57f3ae 100644 --- a/package/network/services/ppp/Makefile +++ b/package/network/services/ppp/Makefile @@ -9,28 +9,38 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=ppp -PKG_RELEASE:=9 +PKG_VERSION:=2.5.1 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL:=https://github.com/paulusmack/ppp -PKG_SOURCE_DATE:=2021-01-04 -PKG_SOURCE_VERSION:=4fb319056f168bb8379865b91b4fd3e1ada73f1e -PKG_MIRROR_HASH:=58b415e17bdcac81bb9594a1b2ba65ec90598817850d22e98c1690e8ed0cd3d8 +PKG_SOURCE_URL:=https://github.com/ppp-project/ppp +PKG_SOURCE_DATE:=2024-09-18 +PKG_SOURCE_VERSION:=d5aeec65752d4a9b3bb46771d0b221c4a4a6539e +PKG_MIRROR_HASH:=b98125933d8160ff3476b053414e787e65a94948c0ecee53f6261cd403ff4b03 + PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=BSD-4-Clause PKG_CPE_ID:=cpe:/a:samba:ppp -PKG_RELEASE_VERSION:=2.4.9 -PKG_VERSION:=$(PKG_RELEASE_VERSION)_git$(subst -,,$(PKG_SOURCE_DATE)) - -PKG_BUILD_DEPENDS:=libpcap - PKG_ASLR_PIE_REGULAR:=1 +PKG_BUILD_DEPENDS:=libpcap PKG_BUILD_FLAGS:=gc-sections lto PKG_BUILD_PARALLEL:=1 +PKG_FIXUP:=autoreconf PKG_INSTALL:=1 include $(INCLUDE_DIR)/package.mk +CONFIGURE_VARS += \ + enable_eaptls=no \ + enable_microsoft_extensions=yes \ + enable_peap=no + +CONFIGURE_ARGS += \ + with_openssl=no \ + with_pam=no \ + with_pcap=no \ + with_srp=no \ + with_static_pcap=yes define Package/ppp/Default SECTION:=net @@ -174,51 +184,23 @@ This tool performs the same discovery process as pppoe, but does not initiate a session. Can be useful to debug pppoe. endef - -define Build/Configure -$(call Build/Configure/Default,, \ - UNAME_S="Linux" \ - UNAME_R="$(LINUX_VERSION)" \ - UNAME_M="$(ARCH)" \ -) - mkdir -p $(PKG_BUILD_DIR)/pppd/plugins/pppoatm/linux - $(CP) \ - $(LINUX_DIR)/include/linux/compiler.h \ - $(LINUX_DIR)/include/$(LINUX_UAPI_DIR)linux/atm*.h \ - $(PKG_BUILD_DIR)/pppd/plugins/pppoatm/linux/ - - # Kernel 4.14.9+ only, ignore the exit status of cp in case the file - # doesn't exits - -$(CP) $(LINUX_DIR)/include/linux/compiler_types.h \ - $(PKG_BUILD_DIR)/pppd/plugins/pppoatm/linux/ -endef - -MAKE_FLAGS += COPTS="$(TARGET_CFLAGS)" \ - PRECOMPILED_FILTER=1 \ - STAGING_DIR="$(STAGING_DIR)" - ifeq ($(BUILD_VARIANT),multilink) - MAKE_FLAGS += HAVE_MULTILINK=y -else - MAKE_FLAGS += HAVE_MULTILINK= -endif - -ifdef CONFIG_USE_MUSL - MAKE_FLAGS += USE_LIBUTIL= + CONFIGURE_VARS += \ + enable_multilink=yes endif define Build/InstallDev $(INSTALL_DIR) $(1)/usr/include - $(CP) $(PKG_INSTALL_DIR)/include/pppd $(1)/usr/include/ + $(CP) $(PKG_INSTALL_DIR)/usr/include/pppd $(1)/usr/include/ endef define Package/ppp/script_install endef define Package/ppp/install - $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION) + $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION) $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppd $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/pppd $(1)/usr/sbin/ $(INSTALL_DIR) $(1)/etc/ppp $(INSTALL_CONF) ./files/etc/ppp/chap-secrets $(1)/etc/ppp/ $(INSTALL_DATA) ./files/etc/ppp/filter $(1)/etc/ppp/ @@ -233,21 +215,21 @@ endef Package/ppp-multilink/install=$(Package/ppp/install) define Package/ppp-mod-pppoa/install - $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION) - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_RELEASE_VERSION)/pppoatm.so \ - $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION)/ + $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION) + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/pppd/$(PKG_VERSION)/pppoatm.so \ + $(1)/usr/lib/pppd/$(PKG_VERSION)/ endef define Package/ppp-mod-pppoe/install - $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION) - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_RELEASE_VERSION)/pppoe.so \ - $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION)/ + $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION) + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/pppd/$(PKG_VERSION)/pppoe.so \ + $(1)/usr/lib/pppd/$(PKG_VERSION)/ endef define Package/ppp-mod-radius/install - $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION) - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_RELEASE_VERSION)/radius.so \ - $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION)/ + $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION) + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/pppd/$(PKG_VERSION)/radius.so \ + $(1)/usr/lib/pppd/$(PKG_VERSION)/ $(INSTALL_DIR) $(1)/etc/ppp $(INSTALL_DATA) ./files/etc/ppp/radius.conf $(1)/etc/ppp/ $(INSTALL_DIR) $(1)/etc/ppp/radius @@ -258,43 +240,43 @@ define Package/ppp-mod-radius/install endef define Package/ppp-mod-pppol2tp/install - $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION) - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_RELEASE_VERSION)/pppol2tp.so \ - $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION)/ + $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION) + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/pppd/$(PKG_VERSION)/pppol2tp.so \ + $(1)/usr/lib/pppd/$(PKG_VERSION)/ endef define Package/ppp-mod-pptp/install - $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION) - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_RELEASE_VERSION)/pptp.so \ - $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION)/ + $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION) + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/pppd/$(PKG_VERSION)/pptp.so \ + $(1)/usr/lib/pppd/$(PKG_VERSION)/ $(INSTALL_DIR) $(1)/etc/ppp $(INSTALL_DATA) ./files/etc/ppp/options.pptp $(1)/etc/ppp/ endef define Package/ppp-mod-passwordfd/install - $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION) - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_RELEASE_VERSION)/passwordfd.so \ - $(1)/usr/lib/pppd/$(PKG_RELEASE_VERSION)/ + $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION) + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/pppd/$(PKG_VERSION)/passwordfd.so \ + $(1)/usr/lib/pppd/$(PKG_VERSION)/ endef define Package/chat/install $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/chat $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/chat $(1)/usr/sbin/ endef define Package/pppdump/install $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppdump $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/pppdump $(1)/usr/sbin/ endef define Package/pppstats/install $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppstats $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/pppstats $(1)/usr/sbin/ endef define Package/pppoe-discovery/install $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppoe-discovery $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/pppoe-discovery $(1)/usr/sbin/ endef $(eval $(call BuildPackage,ppp)) diff --git a/package/network/services/ppp/patches/010-use_target_for_configure.patch b/package/network/services/ppp/patches/010-use_target_for_configure.patch deleted file mode 100644 index 9e8618f83c..0000000000 --- a/package/network/services/ppp/patches/010-use_target_for_configure.patch +++ /dev/null @@ -1,24 +0,0 @@ -configure: Allow overriding uname results - -In a cross compile setting it makes no sense to rely on the "uname" values -reported by the build host system. This patch allows overriding the -"uname -r", "uname -s" and "uname -m" results with the "UNAME_R", "UNAME_S" -and "UNAME_M" environment variables. - -Signed-off-by: Jo-Philipp Wich - ---- a/configure -+++ b/configure -@@ -10,9 +10,9 @@ CROSS_COMPILE= - CC=cc - CFLAGS= - --system=`uname -s` --release=`uname -r` --arch=`uname -m` -+system=${UNAME_S:-`uname -s`} -+release=${UNAME_R:-`uname -r`} -+arch=${UNAME_M:-`uname -m`} - state="unknown" - - case $system in diff --git a/package/network/services/ppp/patches/101-pppd-crypto-fix-build-without-openssl.patch b/package/network/services/ppp/patches/101-pppd-crypto-fix-build-without-openssl.patch new file mode 100644 index 0000000000..eb243694ec --- /dev/null +++ b/package/network/services/ppp/patches/101-pppd-crypto-fix-build-without-openssl.patch @@ -0,0 +1,45 @@ +From: Shiji Yang +Date: Fri, 4 Oct 2024 12:19:42 +0000 +Subject: [PATCH] pppd/crypto: fix build without openssl + +Compile openssl relevant code only when PPP_WITH_OPENSSL is defined. + +Signed-off-by: Shiji Yang +--- + pppd/crypto.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/pppd/crypto.c ++++ b/pppd/crypto.c +@@ -199,6 +199,7 @@ int PPP_crypto_init() + { + int retval = 0; + ++#ifdef PPP_WITH_OPENSSL + #if OPENSSL_VERSION_NUMBER >= 0x30000000L + g_crypto_ctx.legacy = OSSL_PROVIDER_load(NULL, "legacy"); + if (g_crypto_ctx.legacy == NULL) +@@ -214,6 +215,7 @@ int PPP_crypto_init() + goto done; + } + #endif ++#endif + + retval = 1; + +@@ -224,6 +226,7 @@ done: + + int PPP_crypto_deinit() + { ++#ifdef PPP_WITH_OPENSSL + #if OPENSSL_VERSION_NUMBER >= 0x30000000L + if (g_crypto_ctx.legacy) { + OSSL_PROVIDER_unload(g_crypto_ctx.legacy); +@@ -239,6 +242,7 @@ int PPP_crypto_deinit() + #if OPENSSL_VERSION_NUMBER < 0x10100000L + ERR_free_strings(); + #endif ++#endif + return 1; + } + diff --git a/package/network/services/ppp/patches/102-pppd-make-pid-directory-before-create-the-pid-file.patch b/package/network/services/ppp/patches/102-pppd-make-pid-directory-before-create-the-pid-file.patch new file mode 100644 index 0000000000..69e68cdff4 --- /dev/null +++ b/package/network/services/ppp/patches/102-pppd-make-pid-directory-before-create-the-pid-file.patch @@ -0,0 +1,27 @@ +From: Shiji Yang +Date: Fri, 4 Oct 2024 14:02:14 +0000 +Subject: [PATCH] pppd: make pid directory before create the pid file + +If multilink feature is not enabled, the '/var/run/pppd' directory +won't be created before adding pid file. + +Fixes error message: +'Failed to create pid file /var/run/pppd/pppoe-wan.pid: No such file or directory' + +Signed-off-by: Shiji Yang +--- + pppd/main.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/pppd/main.c ++++ b/pppd/main.c +@@ -921,6 +921,9 @@ create_pidfile(int pid) + { + FILE *pidfile; + ++#ifndef PPP_WITH_TDB ++ mkdir_recursive(PPP_PATH_VARRUN); ++#endif + slprintf(pidfilename, sizeof(pidfilename), "%s/%s.pid", + PPP_PATH_VARRUN, ifname); + if ((pidfile = fopen(pidfilename, "w")) != NULL) { diff --git a/package/network/services/ppp/patches/103-pppd-crypto-fix-gcc-14-build.patch b/package/network/services/ppp/patches/103-pppd-crypto-fix-gcc-14-build.patch new file mode 100644 index 0000000000..3a76deb042 --- /dev/null +++ b/package/network/services/ppp/patches/103-pppd-crypto-fix-gcc-14-build.patch @@ -0,0 +1,42 @@ +From: Tan Zien +Date: Tue, 1 Oct 2024 10:38:45 +0800 +Subject: [PATCH] pppd/crypto: fix gcc 14 build + +fix this: + +crypto.c: In function 'PPP_crypto_error': +crypto.c:178:11: error: implicit declaration of function 'vsnprintf' [-Wimplicit-function-declaration] + 178 | off = vsnprintf(buf, len, fmt, args); + | ^~~~~~~~~ +crypto.c:41:1: note: include '' or provide a declaration of 'vsnprintf' + 40 | #include "crypto-priv.h" + +++ |+#include + 41 | +crypto.c:178:26: warning: 'vsnprintf' argument 2 type is 'int' where 'long unsigned int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch] + 178 | off = vsnprintf(buf, len, fmt, args); + | ^~~ +: note: built-in 'vsnprintf' declared here + +Signed-off-by: Tan Zien +--- + pppd/crypto.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/pppd/crypto.c ++++ b/pppd/crypto.c +@@ -34,6 +34,7 @@ + + #include + #include ++#include + + #include "pppd.h" + #include "crypto.h" +@@ -247,7 +248,6 @@ int PPP_crypto_deinit() + } + + #ifdef UNIT_TEST +-#include + + int debug; + int error_count; diff --git a/package/network/services/ppp/patches/105-debian_demand.patch b/package/network/services/ppp/patches/105-debian_demand.patch index ff66aa8ea5..10ce13b253 100644 --- a/package/network/services/ppp/patches/105-debian_demand.patch +++ b/package/network/services/ppp/patches/105-debian_demand.patch @@ -1,6 +1,6 @@ --- a/pppd/demand.c +++ b/pppd/demand.c -@@ -36,6 +36,8 @@ +@@ -40,6 +40,8 @@ #include #include #include @@ -9,16 +9,16 @@ #include #include #include -@@ -43,6 +45,8 @@ +@@ -47,6 +49,8 @@ #include #include #include +#include +#include - #ifdef PPP_FILTER + #ifdef PPP_WITH_FILTER #include #endif -@@ -218,6 +222,14 @@ loop_chars(unsigned char *p, int n) +@@ -223,6 +227,14 @@ loop_chars(unsigned char *p, int n) int c, rv; rv = 0; @@ -33,7 +33,7 @@ for (; n > 0; --n) { c = *p++; if (c == PPP_FLAG) { -@@ -294,16 +306,100 @@ loop_frame(unsigned char *frame, int len +@@ -299,16 +311,100 @@ loop_frame(unsigned char *frame, int len * loopback, now that the real serial link is up. */ void @@ -137,7 +137,7 @@ } else { --- a/pppd/ipcp.c +++ b/pppd/ipcp.c -@@ -1850,7 +1850,7 @@ ipcp_up(fsm *f) +@@ -1915,7 +1915,7 @@ ipcp_up(fsm *f) proxy_arp_set[f->unit] = 1; } @@ -148,7 +148,7 @@ } else { --- a/pppd/ipv6cp.c +++ b/pppd/ipv6cp.c -@@ -1253,7 +1253,7 @@ ipv6cp_up(fsm *f) +@@ -1338,7 +1338,7 @@ ipv6cp_up(fsm *f) if (sif6defaultroute(f->unit, go->ourid, ho->hisid)) default_route_set[f->unit] = 1; } @@ -157,14 +157,14 @@ sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS); } else { ---- a/pppd/pppd.h -+++ b/pppd/pppd.h -@@ -598,7 +598,7 @@ void demand_conf(void); /* config interf +--- a/pppd/pppd-private.h ++++ b/pppd/pppd-private.h +@@ -368,7 +368,7 @@ void demand_conf(void); /* config interf void demand_block(void); /* set all NPs to queue up packets */ void demand_unblock(void); /* set all NPs to pass packets */ void demand_discard(void); /* set all NPs to discard packets */ -void demand_rexmit(int); /* retransmit saved frames for an NP */ -+void demand_rexmit(int, u_int32_t); /* retransmit saved frames for an NP*/ ++void demand_rexmit(int, u_int32_t); /* retransmit saved frames for an NP */ int loop_chars(unsigned char *, int); /* process chars from loopback */ int loop_frame(unsigned char *, int); /* should we bring link up? */ diff --git a/package/network/services/ppp/patches/120-debian_ipv6_updown_option.patch b/package/network/services/ppp/patches/120-debian_ipv6_updown_option.patch deleted file mode 100644 index 11e8d81f43..0000000000 --- a/package/network/services/ppp/patches/120-debian_ipv6_updown_option.patch +++ /dev/null @@ -1,95 +0,0 @@ -pppd: Allow specifying ipv6-up and ipv6-down scripts - -This patch implements the "ipv6-up-script" and "ipv6-down-script" options -which allow to specify the path of the ipv6-up and ipv6-down scripts to call. - -These options default to _PATH_IPV6UP and _PATH_IPV6DOWN to retain the -existing behaviour. - -The patch originated from the Debian project. - -Signed-off-by: Jo-Philipp Wich - ---- a/pppd/main.c -+++ b/pppd/main.c -@@ -295,6 +295,8 @@ main(int argc, char *argv[]) - - strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup)); - strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown)); -+ strlcpy(path_ipv6up, _PATH_IPV6UP, sizeof(path_ipv6up)); -+ strlcpy(path_ipv6down, _PATH_IPV6DOWN, sizeof(path_ipv6down)); - - link_stats_valid = 0; - new_phase(PHASE_INITIALIZE); ---- a/pppd/options.c -+++ b/pppd/options.c -@@ -118,6 +118,8 @@ int req_unit = -1; /* requested interfa - char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */ - char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */ - char req_ifname[MAXIFNAMELEN]; /* requested interface name */ -+char path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */ -+char path_ipv6down[MAXPATHLEN];/* pathname of ipv6-down script */ - bool multilink = 0; /* Enable multilink operation */ - char *bundle_name = NULL; /* bundle name for multilink */ - bool dump_options; /* print out option values */ -@@ -324,6 +326,13 @@ option_t general_options[] = { - "Set pathname of ip-down script", - OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN }, - -+ { "ipv6-up-script", o_string, path_ipv6up, -+ "Set pathname of ipv6-up script", -+ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN }, -+ { "ipv6-down-script", o_string, path_ipv6down, -+ "Set pathname of ipv6-down script", -+ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN }, -+ - #ifdef HAVE_MULTILINK - { "multilink", o_bool, &multilink, - "Enable multilink operation", OPT_PRIO | 1 }, ---- a/pppd/ipv6cp.c -+++ b/pppd/ipv6cp.c -@@ -1295,7 +1295,7 @@ ipv6cp_up(fsm *f) - */ - if (ipv6cp_script_state == s_down && ipv6cp_script_pid == 0) { - ipv6cp_script_state = s_up; -- ipv6cp_script(_PATH_IPV6UP); -+ ipv6cp_script(path_ipv6up); - } - } - -@@ -1346,7 +1346,7 @@ ipv6cp_down(fsm *f) - /* Execute the ipv6-down script */ - if (ipv6cp_script_state == s_up && ipv6cp_script_pid == 0) { - ipv6cp_script_state = s_down; -- ipv6cp_script(_PATH_IPV6DOWN); -+ ipv6cp_script(path_ipv6down); - } - } - -@@ -1384,13 +1384,13 @@ ipv6cp_script_done(void *arg) - case s_up: - if (ipv6cp_fsm[0].state != OPENED) { - ipv6cp_script_state = s_down; -- ipv6cp_script(_PATH_IPV6DOWN); -+ ipv6cp_script(path_ipv6down); - } - break; - case s_down: - if (ipv6cp_fsm[0].state == OPENED) { - ipv6cp_script_state = s_up; -- ipv6cp_script(_PATH_IPV6UP); -+ ipv6cp_script(path_ipv6up); - } - break; - } ---- a/pppd/pppd.h -+++ b/pppd/pppd.h -@@ -328,6 +328,8 @@ extern int req_unit; /* interface unit n - extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */ - extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */ - extern char req_ifname[MAXIFNAMELEN]; /* interface name to use */ -+extern char path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */ -+extern char path_ipv6down[MAXPATHLEN]; /* pathname of ipv6-down script */ - extern bool multilink; /* enable multilink operation */ - extern bool noendpoint; /* don't send or accept endpt. discrim. */ - extern char *bundle_name; /* bundle name for multilink */ diff --git a/package/network/services/ppp/patches/133-fix_sha1_include.patch b/package/network/services/ppp/patches/133-fix_sha1_include.patch deleted file mode 100644 index 357d951441..0000000000 --- a/package/network/services/ppp/patches/133-fix_sha1_include.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/pppd/sha1.c -+++ b/pppd/sha1.c -@@ -19,7 +19,7 @@ - #include - #include - #include /* htonl() */ --#include -+#include "pppd.h" - #include "sha1.h" - - static void diff --git a/package/network/services/ppp/patches/140-pppd-Fix-compilation-with-older-glibc-or-kernel-head.patch b/package/network/services/ppp/patches/140-pppd-Fix-compilation-with-older-glibc-or-kernel-head.patch deleted file mode 100644 index 154ac7270b..0000000000 --- a/package/network/services/ppp/patches/140-pppd-Fix-compilation-with-older-glibc-or-kernel-head.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 98ec18f098e5ef68e3a8cc6954fcaf5a7fb8b7be Mon Sep 17 00:00:00 2001 -From: pali <7141871+pali@users.noreply.github.com> -Date: Mon, 15 Feb 2021 07:54:01 +0100 -Subject: [PATCH] pppd: Fix compilation with older glibc or kernel headers - (#248) -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -glibc versions prior to 2.24 do not define SOL_NETLINK and linux kernel -versions prior to 4.3 do not define NETLINK_CAP_ACK. So add fallback -definitions for these macros into pppd/sys-linux.c file. - -Also extend description why we call SOL_NETLINK/NETLINK_CAP_ACK option. - -Signed-off-by: Pali Rohár ---- - pppd/sys-linux.c | 18 +++++++++++++++++- - 1 file changed, 17 insertions(+), 1 deletion(-) - ---- a/pppd/sys-linux.c -+++ b/pppd/sys-linux.c -@@ -125,6 +125,14 @@ - #include - #include - #include -+/* glibc versions prior to 2.24 do not define SOL_NETLINK */ -+#ifndef SOL_NETLINK -+#define SOL_NETLINK 270 -+#endif -+/* linux kernel versions prior to 4.3 do not define/support NETLINK_CAP_ACK */ -+#ifndef NETLINK_CAP_ACK -+#define NETLINK_CAP_ACK 10 -+#endif - #endif - - #include "pppd.h" -@@ -2843,7 +2851,15 @@ static int append_peer_ipv6_address(unsi - if (fd < 0) - return 0; - -- /* do not ask for error message content */ -+ /* -+ * Tell kernel to not send to us payload of acknowledgment error message. -+ * NETLINK_CAP_ACK option is supported since Linux kernel version 4.3 and -+ * older kernel versions always send full payload in acknowledgment netlink -+ * message. We ignore payload of this message as we need only error code, -+ * to check if our set remote peer address request succeeded or failed. -+ * So ignore return value from the following setsockopt() call as setting -+ * option NETLINK_CAP_ACK means for us just a kernel hint / optimization. -+ */ - one = 1; - setsockopt(fd, SOL_NETLINK, NETLINK_CAP_ACK, &one, sizeof(one)); - diff --git a/package/network/services/ppp/patches/141-Expand-byte-count-statistics-to-64-bits-298.patch b/package/network/services/ppp/patches/141-Expand-byte-count-statistics-to-64-bits-298.patch deleted file mode 100644 index e4de5c0aa2..0000000000 --- a/package/network/services/ppp/patches/141-Expand-byte-count-statistics-to-64-bits-298.patch +++ /dev/null @@ -1,518 +0,0 @@ -From 81ad945630120cc1c27c8bb00503be42b76ff202 Mon Sep 17 00:00:00 2001 -From: Jaco Kroon -Date: Thu, 13 Jan 2022 08:38:04 +0200 -Subject: [PATCH] Expand byte count statistics to 64 bits (#298) - -* Add Gigawords to radius packets where applicable. - -IMPORTANT NOTE: The ioctl() only supports 32-bit counters. In order t -obtain 64-bit counters, these are now pulled in from sysfs (it's assumed -to be mounted on /sys which I'm assuming is standard). - -It is unknown whether sysfs will be available everywhere, as such, keep -the ioctl() method in place, but attempt to detect wrap-overs. - -If the sysfs mechanism fails, fail back to the ioctl(). - -Given maximum data rates, the intervals between calling this needs to be -such that no more than 4GB (2^32) bytes are sent or received in any -given interval. Mostly important for radius plugin where data -accounting may be in effect. - -Towards this, a timer interval on 25 seconds is set to force a ioctl() -poll irrespective of the rate of stats update calls. This may be -important for especially radius that needs to provide interim-update -intervals, if the interim updates is too long and the counters could -wrap-over twice in a single interval. At 25 seconds we should detect -all wraps up to an effective data rate of 1.37Gbps, which for my -purposes is adequate. - -Possible downsides, 4 files are opened, read and closed every time -statistics is requested. This results in 12 system calls every single -time statistics is required, compared to 1 for the ioctl. Efficiency is -unknown, but as a rule of thumb fewer system calls are better, this is -however not a critical path in my opinion, so should not be a problem. -If required I can run a few benchmarks using gettimeofday() to measure -actual impact. - -Signed-off-by: Jaco Kroon - -* Use netlink if possible to obtain 64-bit stats. - -This uses two system calls per round. - -This should be preferred where available. It seems the RTM_GETSTATS was -only added from 2016 some point (4.7.0 as per pali), which is in my -opinion old, but given experience with certain embedded systems does -need to be supported. - -Signed-off-by: Jaco Kroon - -Co-authored-by: Jaco Kroon ---- - pppd/main.c | 5 +- - pppd/plugins/radius/etc/dictionary | 2 + - pppd/plugins/radius/radius.c | 28 ++- - pppd/plugins/radius/radiusclient.h | 2 + - pppd/pppd.h | 9 +- - pppd/sys-linux.c | 281 ++++++++++++++++++++++++++++- - 6 files changed, 313 insertions(+), 14 deletions(-) - ---- a/pppd/main.c -+++ b/pppd/main.c -@@ -87,6 +87,7 @@ - #include - #include - #include -+#include - - #include "pppd.h" - #include "magic.h" -@@ -1230,9 +1231,9 @@ update_link_stats(int u) - - slprintf(numbuf, sizeof(numbuf), "%u", link_connect_time); - script_setenv("CONNECT_TIME", numbuf, 0); -- slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_out); -+ snprintf(numbuf, sizeof(numbuf), "%" PRIu64, link_stats.bytes_out); - script_setenv("BYTES_SENT", numbuf, 0); -- slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_in); -+ snprintf(numbuf, sizeof(numbuf), "%" PRIu64, link_stats.bytes_in); - script_setenv("BYTES_RCVD", numbuf, 0); - } - ---- a/pppd/plugins/radius/etc/dictionary -+++ b/pppd/plugins/radius/etc/dictionary -@@ -82,6 +82,8 @@ ATTRIBUTE Acct-Session-Time 46 integer - ATTRIBUTE Acct-Input-Packets 47 integer - ATTRIBUTE Acct-Output-Packets 48 integer - ATTRIBUTE Acct-Terminate-Cause 49 integer -+ATTRIBUTE Acct-Input-Gigawords 52 integer -+ATTRIBUTE Acct-Output-Gigawords 53 integer - ATTRIBUTE Chap-Challenge 60 string - ATTRIBUTE NAS-Port-Type 61 integer - ATTRIBUTE Port-Limit 62 integer ---- a/pppd/plugins/radius/radius.c -+++ b/pppd/plugins/radius/radius.c -@@ -1020,12 +1020,22 @@ radius_acct_stop(void) - av_type = link_connect_time; - rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE); - -- av_type = link_stats.bytes_out; -+ av_type = link_stats.bytes_out & 0xFFFFFFFF; - rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE); - -- av_type = link_stats.bytes_in; -+ if (link_stats.bytes_out > 0xFFFFFFFF) { -+ av_type = link_stats.bytes_out >> 32; -+ rc_avpair_add(&send, PW_ACCT_OUTPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE); -+ } -+ -+ av_type = link_stats.bytes_in & 0xFFFFFFFF; - rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE); - -+ if (link_stats.bytes_in > 0xFFFFFFFF) { -+ av_type = link_stats.bytes_in >> 32; -+ rc_avpair_add(&send, PW_ACCT_INPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE); -+ } -+ - av_type = link_stats.pkts_out; - rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE); - -@@ -1172,12 +1182,22 @@ radius_acct_interim(void *ignored) - av_type = link_connect_time; - rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE); - -- av_type = link_stats.bytes_out; -+ av_type = link_stats.bytes_out & 0xFFFFFFFF; - rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE); - -- av_type = link_stats.bytes_in; -+ if (link_stats.bytes_out > 0xFFFFFFFF) { -+ av_type = link_stats.bytes_out >> 32; -+ rc_avpair_add(&send, PW_ACCT_OUTPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE); -+ } -+ -+ av_type = link_stats.bytes_in & 0xFFFFFFFF; - rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE); - -+ if (link_stats.bytes_in > 0xFFFFFFFF) { -+ av_type = link_stats.bytes_in >> 32; -+ rc_avpair_add(&send, PW_ACCT_INPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE); -+ } -+ - av_type = link_stats.pkts_out; - rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE); - ---- a/pppd/plugins/radius/radiusclient.h -+++ b/pppd/plugins/radius/radiusclient.h -@@ -184,6 +184,8 @@ typedef struct pw_auth_hdr - #define PW_ACCT_LINK_COUNT 51 /* integer */ - - /* From RFC 2869 */ -+#define PW_ACCT_INPUT_GIGAWORDS 52 /* integer */ -+#define PW_ACCT_OUTPUT_GIGAWORDS 53 /* integer */ - #define PW_ACCT_INTERIM_INTERVAL 85 /* integer */ - - /* Merit Experimental Extensions */ ---- a/pppd/pppd.h -+++ b/pppd/pppd.h -@@ -53,6 +53,7 @@ - #include /* for encrypt */ - #include /* for setkey */ - #include -+#include - #include /* for NGROUPS_MAX */ - #include /* for MAXPATHLEN and BSD4_4, if defined */ - #include /* for u_int32_t, if defined */ -@@ -173,8 +174,8 @@ struct permitted_ip { - * pppd needs. - */ - struct pppd_stats { -- unsigned int bytes_in; -- unsigned int bytes_out; -+ uint64_t bytes_in; -+ uint64_t bytes_out; - unsigned int pkts_in; - unsigned int pkts_out; - }; -@@ -347,7 +348,7 @@ extern char *max_tls_version; - extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */ - extern int maxoctets_dir; /* Direction : - 0 - in+out (default) -- 1 - in -+ 1 - in - 2 - out - 3 - max(in,out) */ - extern int maxoctets_timeout; /* Timeout for check of octets limit */ -@@ -356,7 +357,7 @@ extern int maxoctets_timeout; /* - #define PPP_OCTETS_DIRECTION_OUT 2 - #define PPP_OCTETS_DIRECTION_MAXOVERAL 3 - /* same as previos, but little different on RADIUS side */ --#define PPP_OCTETS_DIRECTION_MAXSESSION 4 -+#define PPP_OCTETS_DIRECTION_MAXSESSION 4 - #endif - - #ifdef PPP_FILTER ---- a/pppd/sys-linux.c -+++ b/pppd/sys-linux.c -@@ -79,6 +79,7 @@ - #include - - #include -+#include - #include - #include - #include -@@ -92,6 +93,7 @@ - #include - #include - #include -+#include - - /* This is in netdevice.h. However, this compile will fail miserably if - you attempt to include netdevice.h because it has so many references -@@ -121,9 +123,19 @@ - #include - #include - --#ifdef INET6 - #include - #include -+#include -+/* Attempt at retaining compile-support with older than 4.7 kernels, or kernels -+ * where RTM_NEWSTATS isn't defined for whatever reason. -+ */ -+#ifndef RTM_NEWSTATS -+#define RTM_NEWSTATS 92 -+#define RTM_GETSTATS 94 -+#define IFLA_STATS_LINK_64 1 -+#endif -+ -+#ifdef INET6 - #include - /* glibc versions prior to 2.24 do not define SOL_NETLINK */ - #ifndef SOL_NETLINK -@@ -1407,11 +1419,17 @@ get_idle_time(int u, struct ppp_idle *ip - - /******************************************************************** - * -- * get_ppp_stats - return statistics for the link. -+ * get_ppp_stats_iocl - return statistics for the link, using the ioctl() method, -+ * this only supports 32-bit counters, so need to count the wraps. - */ --int --get_ppp_stats(int u, struct pppd_stats *stats) -+static int -+get_ppp_stats_ioctl(int u, struct pppd_stats *stats) - { -+ static u_int32_t previbytes = 0; -+ static u_int32_t prevobytes = 0; -+ static u_int32_t iwraps = 0; -+ static u_int32_t owraps = 0; -+ - struct ifpppstatsreq req; - - memset (&req, 0, sizeof (req)); -@@ -1426,7 +1444,262 @@ get_ppp_stats(int u, struct pppd_stats * - stats->bytes_out = req.stats.p.ppp_obytes; - stats->pkts_in = req.stats.p.ppp_ipackets; - stats->pkts_out = req.stats.p.ppp_opackets; -+ -+ if (stats->bytes_in < previbytes) -+ ++iwraps; -+ if (stats->bytes_out < prevobytes) -+ ++owraps; -+ -+ previbytes = stats->bytes_in; -+ prevobytes = stats->bytes_out; -+ -+ stats->bytes_in += (uint64_t)iwraps << 32; -+ stats->bytes_out += (uint64_t)owraps << 32; -+ -+ return 1; -+} -+ -+/******************************************************************** -+ * get_ppp_stats_rtnetlink - return statistics for the link, using rtnetlink -+ * This provides native 64-bit counters. -+ */ -+static int -+get_ppp_stats_rtnetlink(int u, struct pppd_stats *stats) -+{ -+ static int rtnl_fd = -1; -+ -+ struct sockaddr_nl nladdr; -+ struct { -+ struct nlmsghdr nlh; -+ struct if_stats_msg ifsm; -+ } nlreq; -+ struct nlresp { -+ struct nlmsghdr nlh; -+ union { -+ struct { -+ struct nlmsgerr nlerr; -+ char __end_err[0]; -+ }; -+ struct { -+ struct rtmsg rth; -+ struct { -+ /* We only case about these first fields from rtnl_link_stats64 */ -+ uint64_t rx_packets; -+ uint64_t tx_packets; -+ uint64_t rx_bytes; -+ uint64_t tx_bytes; -+ } stats; -+ char __end_stats[0]; -+ }; -+ }; -+ } nlresp; -+ ssize_t nlresplen; -+ struct iovec iov; -+ struct msghdr msg; -+ -+ memset(&nladdr, 0, sizeof(nladdr)); -+ nladdr.nl_family = AF_NETLINK; -+ -+ if (rtnl_fd < 0) { -+ rtnl_fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); -+ if (rtnl_fd < 0) { -+ error("get_ppp_stats_rtnetlink: error creating NETLINK socket: %m (line %d)", __LINE__); -+ return 0; -+ } -+ -+ if (bind(rtnl_fd, (struct sockaddr *)&nladdr, sizeof(nladdr)) < 0) { -+ error("get_ppp_stats_rtnetlink: bind(AF_NETLINK): %m (line %d)", __LINE__); -+ goto err; -+ } -+ } -+ -+ memset(&nlreq, 0, sizeof(nlreq)); -+ nlreq.nlh.nlmsg_len = sizeof(nlreq); -+ nlreq.nlh.nlmsg_type = RTM_GETSTATS; -+ nlreq.nlh.nlmsg_flags = NLM_F_REQUEST; -+ -+ nlreq.ifsm.ifindex = if_nametoindex(ifname); -+ nlreq.ifsm.filter_mask = IFLA_STATS_LINK_64; -+ -+ memset(&iov, 0, sizeof(iov)); -+ iov.iov_base = &nlreq; -+ iov.iov_len = sizeof(nlreq); -+ -+ memset(&msg, 0, sizeof(msg)); -+ msg.msg_name = &nladdr; -+ msg.msg_namelen = sizeof(nladdr); -+ msg.msg_iov = &iov; -+ msg.msg_iovlen = 1; -+ -+ if (sendmsg(rtnl_fd, &msg, 0) < 0) { -+ error("get_ppp_stats_rtnetlink: sendmsg(RTM_GETSTATS): %m (line %d)", __LINE__); -+ goto err; -+ } -+ -+ /* We just need to repoint to IOV ... everything else stays the same */ -+ iov.iov_base = &nlresp; -+ iov.iov_len = sizeof(nlresp); -+ -+ nlresplen = recvmsg(rtnl_fd, &msg, 0); -+ -+ if (nlresplen < 0) { -+ error("get_ppp_stats_rtnetlink: recvmsg(RTM_GETSTATS): %m (line %d)", __LINE__); -+ goto err; -+ } -+ -+ if (nlresplen < sizeof(nlresp.nlh)) { -+ error("get_ppp_stats_rtnetlink: Netlink response message was incomplete (line %d)", __LINE__); -+ goto err; -+ } -+ -+ if (nlresp.nlh.nlmsg_type == NLMSG_ERROR) { -+ if (nlresplen < offsetof(struct nlresp, __end_err)) { -+ if (kernel_version >= KVERSION(4,7,0)) -+ error("get_ppp_stats_rtnetlink: Netlink responded with error: %s (line %d)", strerror(-nlresp.nlerr.error), __LINE__); -+ } else { -+ error("get_ppp_stats_rtnetlink: Netlink responded with an error message, but the nlmsgerr structure is incomplete (line %d).", -+ __LINE__); -+ } -+ goto err; -+ } -+ -+ if (nlresp.nlh.nlmsg_type != RTM_NEWSTATS) { -+ error("get_ppp_stats_rtnetlink: Expected RTM_NEWSTATS response, found something else (mlmsg_type %d, line %d)", -+ nlresp.nlh.nlmsg_type, __LINE__); -+ goto err; -+ } -+ -+ if (nlresplen < offsetof(struct nlresp, __end_stats)) { -+ error("get_ppp_stats_rtnetlink: Obtained an insufficiently sized rtnl_link_stats64 struct from the kernel (line %d).", __LINE__); -+ goto err; -+ } -+ -+ stats->bytes_in = nlresp.stats.rx_bytes; -+ stats->bytes_out = nlresp.stats.tx_bytes; -+ stats->pkts_in = nlresp.stats.rx_packets; -+ stats->pkts_out = nlresp.stats.tx_packets; -+ - return 1; -+err: -+ close(rtnl_fd); -+ rtnl_fd = -1; -+ return 0; -+} -+ -+/******************************************************************** -+ * get_ppp_stats_sysfs - return statistics for the link, using the files in sysfs, -+ * this provides native 64-bit counters. -+ */ -+static int -+get_ppp_stats_sysfs(int u, struct pppd_stats *stats) -+{ -+ char fname[PATH_MAX+1]; -+ char buf[21], *err; /* 2^64 < 10^20 */ -+ int blen, fd, rlen; -+ unsigned long long val; -+ -+ struct { -+ const char* fname; -+ void* ptr; -+ unsigned size; -+ } slist[] = { -+#define statfield(fn, field) { .fname = #fn, .ptr = &stats->field, .size = sizeof(stats->field) } -+ statfield(rx_bytes, bytes_in), -+ statfield(tx_bytes, bytes_out), -+ statfield(rx_packets, pkts_in), -+ statfield(tx_packets, pkts_out), -+#undef statfield -+ }; -+ -+ blen = snprintf(fname, sizeof(fname), "/sys/class/net/%s/statistics/", ifname); -+ if (blen >= sizeof(fname)) -+ return 0; /* ifname max 15, so this should be impossible */ -+ -+ for (int i = 0; i < sizeof(slist) / sizeof(*slist); ++i) { -+ if (snprintf(fname + blen, sizeof(fname) - blen, "%s", slist[i].fname) >= sizeof(fname) - blen) { -+ fname[blen] = 0; -+ error("sysfs stats: filename %s/%s overflowed PATH_MAX", fname, slist[i].fname); -+ return 0; -+ } -+ -+ fd = open(fname, O_RDONLY); -+ if (fd < 0) { -+ error("%s: %m", fname); -+ return 0; -+ } -+ -+ rlen = read(fd, buf, sizeof(buf) - 1); -+ close(fd); -+ if (rlen < 0) { -+ error("%s: %m", fname); -+ return 0; -+ } -+ /* trim trailing \n if present */ -+ while (rlen > 0 && buf[rlen-1] == '\n') -+ rlen--; -+ buf[rlen] = 0; -+ -+ errno = 0; -+ val = strtoull(buf, &err, 10); -+ if (*buf < '0' || *buf > '9' || errno != 0 || *err) { -+ error("string to number conversion error converting %s (from %s) for remaining string %s%s%s", -+ buf, fname, err, errno ? ": " : "", errno ? strerror(errno) : ""); -+ return 0; -+ } -+ switch (slist[i].size) { -+#define stattype(type) case sizeof(type): *(type*)slist[i].ptr = (type)val; break -+ stattype(uint64_t); -+ stattype(uint32_t); -+ stattype(uint16_t); -+ stattype(uint8_t); -+#undef stattype -+ default: -+ error("Don't know how to store stats for %s of size %u", slist[i].fname, slist[i].size); -+ return 0; -+ } -+ } -+ -+ return 1; -+} -+ -+/******************************************************************** -+ * Periodic timer function to be used to keep stats up to date in case of ioctl -+ * polling. -+ * -+ * Given the 25s interval this should be fine up to data rates of 1.37Gbps. -+ * If you do change the timer, remember to also bring the get_ppp_stats (which -+ * sets up the initial trigger) as well. -+ */ -+static void -+ppp_stats_poller(void* u) -+{ -+ struct pppd_stats dummy; -+ get_ppp_stats_ioctl((long)u, &dummy); -+ TIMEOUT(ppp_stats_poller, u, 25); -+} -+ -+/******************************************************************** -+ * get_ppp_stats - return statistics for the link. -+ */ -+int get_ppp_stats(int u, struct pppd_stats *stats) -+{ -+ static int (*func)(int, struct pppd_stats*) = NULL; -+ -+ if (!func) { -+ if (get_ppp_stats_rtnetlink(u, stats)) { -+ func = get_ppp_stats_rtnetlink; -+ return 1; -+ } -+ if (get_ppp_stats_sysfs(u, stats)) { -+ func = get_ppp_stats_sysfs; -+ return 1; -+ } -+ warn("statistics falling back to ioctl which only supports 32-bit counters"); -+ func = get_ppp_stats_ioctl; -+ TIMEOUT(ppp_stats_poller, (void*)(long)u, 25); -+ } -+ -+ return func(u, stats); - } - - /******************************************************************** diff --git a/package/network/services/ppp/patches/142-pppd-Add-support-for-registering-ppp-interface-via-L.patch b/package/network/services/ppp/patches/142-pppd-Add-support-for-registering-ppp-interface-via-L.patch deleted file mode 100644 index 9987d3dce9..0000000000 --- a/package/network/services/ppp/patches/142-pppd-Add-support-for-registering-ppp-interface-via-L.patch +++ /dev/null @@ -1,299 +0,0 @@ -From 4a54e34cf5629f9fed61f0b7d69ee3ba4d874bc6 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Pali=20Roh=C3=A1r?= -Date: Sat, 9 Jul 2022 13:40:24 +0200 -Subject: [PATCH] pppd: Add support for registering ppp interface via Linux - rtnetlink API -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -pppd currently creates ppp network interface via PPPIOCNEWUNIT ioctl API. -This API creates a new ppp network interface named "ppp". If user -supply option "ifname" with custom network name then pppd calls SIOCSIFNAME -ioctl to rename "ppp" to custom name immediately after successful -PPPIOCNEWUNIT ioctl call. If custom name is already registered then -SIOCSIFNAME ioctl fails and pppd close current channel (which destroy also -network interface). - -This has side effect that in the first few miliseconds interface has -different name as what user supplied. - -Tools like systemd, udev or NetworkManager are trying to query -interface attributes based on interface name immediately when new -network interface is created. - -But if interface is renamed immediately after creation then these tools -fails. For example when running pppd with option "ifname ppp-wan" following -error is reported by systemd / udev into dmesg log: - - [ 35.718732] PPP generic driver version 2.4.2 - [ 35.793914] NET: Registered protocol family 24 - [ 35.889924] systemd-udevd[1852]: link_config: autonegotiation is unset or enabled, the speed and duplex are not writable. - [ 35.901450] ppp-wan: renamed from ppp0 - [ 35.930332] systemd-udevd[1852]: link_config: could not get ethtool features for ppp0 - [ 35.939473] systemd-udevd[1852]: Could not set offload features of ppp0: No such device - -There is an easy way to fix this issue: Use new rtnetlink API. - -Via rtnetlink API it is possible to create ppp network interface with -custom ifname atomically. Just it is not possible to specify custom ppp -unit id. - -So use new rtnetlink API when user requested custom ifname without custom -ppp unit id. This will avoid system issues with interface renaming as ppp -interface is directly registered with specified final name. - -This has also advantage that if requested interface name already exists -then pppd fail during registering of networking interface and not during -renaming network interface which happens after successful registration. - -If user supply custom ppp unit id then it is required to use old ioctl API -as currently it is the only API which allows specifying ppp unit id. - -When user does not specify custom ifname stay also with old ioctl API. -There is currently a bug in kernel which cause that when empty interface is -specified in rtnetlink message for creating ppp interface then kernel -creates ppp interface but with pseudo-random name, not derived from ppp -unit id. And therefore it is not possible to retrieve what is the name of -newly created network interface. So when user does not specify interface -name via "ifname" option (which means that want from kernel to choose some -"free" interface name) it is needed to use old ioctl API which do it -correctly for now. - -Signed-off-by: Pali Rohár ---- - pppd/sys-linux.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 192 insertions(+), 2 deletions(-) - ---- a/pppd/sys-linux.c -+++ b/pppd/sys-linux.c -@@ -126,6 +126,11 @@ - #include - #include - #include -+ -+#ifdef INET6 -+#include -+#endif -+ - /* Attempt at retaining compile-support with older than 4.7 kernels, or kernels - * where RTM_NEWSTATS isn't defined for whatever reason. - */ -@@ -135,16 +140,20 @@ - #define IFLA_STATS_LINK_64 1 - #endif - --#ifdef INET6 --#include - /* glibc versions prior to 2.24 do not define SOL_NETLINK */ - #ifndef SOL_NETLINK - #define SOL_NETLINK 270 - #endif -+ - /* linux kernel versions prior to 4.3 do not define/support NETLINK_CAP_ACK */ - #ifndef NETLINK_CAP_ACK - #define NETLINK_CAP_ACK 10 - #endif -+ -+/* linux kernel versions prior to 4.7 do not define/support IFLA_PPP_DEV_FD */ -+#ifndef IFLA_PPP_MAX -+/* IFLA_PPP_DEV_FD is declared as enum when IFLA_PPP_MAX is defined */ -+#define IFLA_PPP_DEV_FD 1 - #endif - - #include "pppd.h" -@@ -657,6 +666,160 @@ void generic_disestablish_ppp(int dev_fd - } - - /* -+ * make_ppp_unit_rtnetlink - register a new ppp network interface for ppp_dev_fd -+ * with specified req_ifname via rtnetlink. Interface name req_ifname must not -+ * be empty. Custom ppp unit id req_unit is ignored and kernel choose some free. -+ */ -+static int make_ppp_unit_rtnetlink(void) -+{ -+ struct { -+ struct nlmsghdr nlh; -+ struct ifinfomsg ifm; -+ struct { -+ struct rtattr rta; -+ char ifname[IFNAMSIZ]; -+ } ifn; -+ struct { -+ struct rtattr rta; -+ struct { -+ struct rtattr rta; -+ char ifkind[sizeof("ppp")]; -+ } ifik; -+ struct { -+ struct rtattr rta; -+ struct { -+ struct rtattr rta; -+ union { -+ int ppp_dev_fd; -+ } ppp; -+ } ifdata[1]; -+ } ifid; -+ } ifli; -+ } nlreq; -+ struct { -+ struct nlmsghdr nlh; -+ struct nlmsgerr nlerr; -+ } nlresp; -+ struct sockaddr_nl nladdr; -+ struct iovec iov; -+ struct msghdr msg; -+ ssize_t nlresplen; -+ int one; -+ int fd; -+ -+ fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); -+ if (fd < 0) { -+ error("make_ppp_unit_rtnetlink: socket(NETLINK_ROUTE): %m (line %d)", __LINE__); -+ return 0; -+ } -+ -+ /* Tell kernel to not send to us payload of acknowledgment error message. */ -+ one = 1; -+ setsockopt(fd, SOL_NETLINK, NETLINK_CAP_ACK, &one, sizeof(one)); -+ -+ memset(&nladdr, 0, sizeof(nladdr)); -+ nladdr.nl_family = AF_NETLINK; -+ -+ if (bind(fd, (struct sockaddr *)&nladdr, sizeof(nladdr)) < 0) { -+ error("make_ppp_unit_rtnetlink: bind(AF_NETLINK): %m (line %d)", __LINE__); -+ close(fd); -+ return 0; -+ } -+ -+ memset(&nlreq, 0, sizeof(nlreq)); -+ nlreq.nlh.nlmsg_len = sizeof(nlreq); -+ nlreq.nlh.nlmsg_type = RTM_NEWLINK; -+ nlreq.nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_EXCL | NLM_F_CREATE; -+ nlreq.ifm.ifi_family = AF_UNSPEC; -+ nlreq.ifm.ifi_type = ARPHRD_NETROM; -+ nlreq.ifn.rta.rta_len = sizeof(nlreq.ifn); -+ nlreq.ifn.rta.rta_type = IFLA_IFNAME; -+ strlcpy(nlreq.ifn.ifname, req_ifname, sizeof(nlreq.ifn.ifname)); -+ nlreq.ifli.rta.rta_len = sizeof(nlreq.ifli); -+ nlreq.ifli.rta.rta_type = IFLA_LINKINFO; -+ nlreq.ifli.ifik.rta.rta_len = sizeof(nlreq.ifli.ifik); -+ nlreq.ifli.ifik.rta.rta_type = IFLA_INFO_KIND; -+ strcpy(nlreq.ifli.ifik.ifkind, "ppp"); -+ nlreq.ifli.ifid.rta.rta_len = sizeof(nlreq.ifli.ifid); -+ nlreq.ifli.ifid.rta.rta_type = IFLA_INFO_DATA; -+ nlreq.ifli.ifid.ifdata[0].rta.rta_len = sizeof(nlreq.ifli.ifid.ifdata[0]); -+ nlreq.ifli.ifid.ifdata[0].rta.rta_type = IFLA_PPP_DEV_FD; -+ nlreq.ifli.ifid.ifdata[0].ppp.ppp_dev_fd = ppp_dev_fd; -+ -+ memset(&nladdr, 0, sizeof(nladdr)); -+ nladdr.nl_family = AF_NETLINK; -+ -+ memset(&iov, 0, sizeof(iov)); -+ iov.iov_base = &nlreq; -+ iov.iov_len = sizeof(nlreq); -+ -+ memset(&msg, 0, sizeof(msg)); -+ msg.msg_name = &nladdr; -+ msg.msg_namelen = sizeof(nladdr); -+ msg.msg_iov = &iov; -+ msg.msg_iovlen = 1; -+ -+ if (sendmsg(fd, &msg, 0) < 0) { -+ error("make_ppp_unit_rtnetlink: sendmsg(RTM_NEWLINK/NLM_F_CREATE): %m (line %d)", __LINE__); -+ close(fd); -+ return 0; -+ } -+ -+ memset(&iov, 0, sizeof(iov)); -+ iov.iov_base = &nlresp; -+ iov.iov_len = sizeof(nlresp); -+ -+ memset(&msg, 0, sizeof(msg)); -+ msg.msg_name = &nladdr; -+ msg.msg_namelen = sizeof(nladdr); -+ msg.msg_iov = &iov; -+ msg.msg_iovlen = 1; -+ -+ nlresplen = recvmsg(fd, &msg, 0); -+ -+ if (nlresplen < 0) { -+ error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): %m (line %d)", __LINE__); -+ close(fd); -+ return 0; -+ } -+ -+ close(fd); -+ -+ if (nladdr.nl_family != AF_NETLINK) { -+ error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): Not a netlink packet (line %d)", __LINE__); -+ return 0; -+ } -+ -+ if ((size_t)nlresplen < sizeof(nlresp) || nlresp.nlh.nlmsg_len < sizeof(nlresp)) { -+ error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): Acknowledgment netlink packet too short (line %d)", __LINE__); -+ return 0; -+ } -+ -+ /* acknowledgment packet for NLM_F_ACK is NLMSG_ERROR */ -+ if (nlresp.nlh.nlmsg_type != NLMSG_ERROR) { -+ error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): Not an acknowledgment netlink packet (line %d)", __LINE__); -+ return 0; -+ } -+ -+ /* error == 0 indicates success, negative value is errno code */ -+ if (nlresp.nlerr.error != 0) { -+ /* -+ * Linux kernel versions prior to 4.7 do not support creating ppp -+ * interfaces via rtnetlink API and therefore error response is -+ * expected. On older kernel versions do not show this error message. -+ * When error is different than EEXIST then pppd tries to fallback to -+ * the old ioctl method. -+ */ -+ errno = (nlresp.nlerr.error < 0) ? -nlresp.nlerr.error : EINVAL; -+ if (kernel_version >= KVERSION(4,7,0)) -+ error("Couldn't create ppp interface %s: %m", req_ifname); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+/* - * make_ppp_unit - make a new ppp unit for ppp_dev_fd. - * Assumes new_style_driver. - */ -@@ -676,6 +839,33 @@ static int make_ppp_unit(void) - || fcntl(ppp_dev_fd, F_SETFL, flags | O_NONBLOCK) == -1) - warn("Couldn't set /dev/ppp to nonblock: %m"); - -+ /* -+ * Via rtnetlink it is possible to create ppp network interface with -+ * custom ifname atomically. But it is not possible to specify custom -+ * ppp unit id. -+ * -+ * Tools like systemd, udev or NetworkManager are trying to query -+ * interface attributes based on interface name immediately when new -+ * network interface is created. And therefore immediate interface -+ * renaming is causing issues. -+ * -+ * So use rtnetlink API only when user requested custom ifname. It will -+ * avoid system issues with interface renaming. -+ */ -+ if (req_unit == -1 && req_ifname[0] != '\0' && kernel_version >= KVERSION(2,1,16)) { -+ if (make_ppp_unit_rtnetlink()) { -+ if (ioctl(ppp_dev_fd, PPPIOCGUNIT, &ifunit)) -+ fatal("Couldn't retrieve PPP unit id: %m"); -+ return 0; -+ } -+ /* -+ * If interface with requested name already exist return error -+ * otherwise fallback to old ioctl method. -+ */ -+ if (errno == EEXIST) -+ return -1; -+ } -+ - ifunit = req_unit; - x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); - if (x < 0 && req_unit >= 0 && errno == EEXIST) { diff --git a/package/network/services/ppp/patches/143-pppd-Workaround-for-generating-ppp-unit-id-on-Linux-.patch b/package/network/services/ppp/patches/143-pppd-Workaround-for-generating-ppp-unit-id-on-Linux-.patch deleted file mode 100644 index abe559e074..0000000000 --- a/package/network/services/ppp/patches/143-pppd-Workaround-for-generating-ppp-unit-id-on-Linux-.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 44609bfc974bdafc0316d069aabf5e2903efa805 Mon Sep 17 00:00:00 2001 -From: pali <7141871+pali@users.noreply.github.com> -Date: Tue, 9 Aug 2022 11:20:15 +0200 -Subject: [PATCH] pppd: Workaround for generating ppp unit id on Linux (#355) -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Linux kernel has nasty bug / feature. If PPPIOCNEWUNIT is called with -negative ppp unit id (which is default option when command line argument -"unit" is not specified; and tells kernel to choose some free ppp unit id) -and the lowest unused/free ppp unit id is present in some existing network -interface name prefixed by "ppp" string then this PPPIOCNEWUNIT ioctl -fails. In this case kernel is basically unable to create a new ppp -interface via PPPIOCNEWUNIT ioctl when user does not specify some unused -and non-conflicted unit id. - -Linux kernel should be fixed to choose usable ppp unit id when was -requested via PPPIOCNEWUNIT parameter -1. - -Until this happens, add a workaround for pppd to help choosing some random -ppp unit id when kernel returns this error. - -Simple test case (run on system when there is no ppp interface): - - sudo ./pppd ifname ppp1 nodefaultroute noauth nolock local nodetach pty "./pppd nodefaultroute noauth nolock local nodetach notty" - -Second pppd process without this patch prints into syslog following error: - - pppd 2.4.10-dev started by pali, uid 0 - Couldn't create new ppp unit: File exists - Exit. - -With this patch it falls back to random ppp unit id and succeeds: - - pppd 2.4.10-dev started by pali, uid 0 - Using interface ppp1361 - Connect: ppp1361 <--> /dev/pts/14 - ... - -Signed-off-by: Pali Rohár ---- - pppd/sys-linux.c | 5 +++++ - 1 file changed, 5 insertions(+) - ---- a/pppd/sys-linux.c -+++ b/pppd/sys-linux.c -@@ -873,6 +873,11 @@ static int make_ppp_unit(void) - ifunit = -1; - x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); - } -+ if (x < 0 && errno == EEXIST) { -+ srand(time(NULL) * getpid()); -+ ifunit = rand() % 10000; -+ x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); -+ } - if (x < 0) - error("Couldn't create new ppp unit: %m"); - diff --git a/package/network/services/ppp/patches/144-pppd-Retry-registering-interface-when-on-rtnetlink-E.patch b/package/network/services/ppp/patches/144-pppd-Retry-registering-interface-when-on-rtnetlink-E.patch deleted file mode 100644 index 26c1e34683..0000000000 --- a/package/network/services/ppp/patches/144-pppd-Retry-registering-interface-when-on-rtnetlink-E.patch +++ /dev/null @@ -1,218 +0,0 @@ -From 089687fbcc6524809ae9f4b2f8145fe3c2a91147 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Pali=20Roh=C3=A1r?= -Date: Sat, 7 Aug 2021 19:48:01 +0200 -Subject: [PATCH] pppd: Retry registering interface when on rtnetlink -EBUSY - error -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Due to workaround in kernel module ppp_generic.ko in function -ppp_nl_newlink(), kernel may return -EBUSY error to prevent possible -mutex deadlock. In this case userspace needs to retry its request. - -Proper way would be to fix kernel module to order requests and mutex -locking, so prevent deadlock in kernel and so never return this error to -userspace. Until it happens we need retry code in userspace. - -Signed-off-by: Pali Rohár -[ backport to ppp 2.4.9 ] -Signed-off-by: Christian Marangi ---- - pppd/sys-linux.c | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - ---- a/pppd/sys-linux.c -+++ b/pppd/sys-linux.c -@@ -707,99 +707,101 @@ static int make_ppp_unit_rtnetlink(void) - int one; - int fd; - -- fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); -- if (fd < 0) { -- error("make_ppp_unit_rtnetlink: socket(NETLINK_ROUTE): %m (line %d)", __LINE__); -- return 0; -- } -- -- /* Tell kernel to not send to us payload of acknowledgment error message. */ -- one = 1; -- setsockopt(fd, SOL_NETLINK, NETLINK_CAP_ACK, &one, sizeof(one)); -+ do { -+ fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); -+ if (fd < 0) { -+ error("make_ppp_unit_rtnetlink: socket(NETLINK_ROUTE): %m (line %d)", __LINE__); -+ return 0; -+ } -+ -+ /* Tell kernel to not send to us payload of acknowledgment error message. */ -+ one = 1; -+ setsockopt(fd, SOL_NETLINK, NETLINK_CAP_ACK, &one, sizeof(one)); -+ -+ memset(&nladdr, 0, sizeof(nladdr)); -+ nladdr.nl_family = AF_NETLINK; -+ -+ if (bind(fd, (struct sockaddr *)&nladdr, sizeof(nladdr)) < 0) { -+ error("make_ppp_unit_rtnetlink: bind(AF_NETLINK): %m (line %d)", __LINE__); -+ close(fd); -+ return 0; -+ } -+ -+ memset(&nlreq, 0, sizeof(nlreq)); -+ nlreq.nlh.nlmsg_len = sizeof(nlreq); -+ nlreq.nlh.nlmsg_type = RTM_NEWLINK; -+ nlreq.nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_EXCL | NLM_F_CREATE; -+ nlreq.ifm.ifi_family = AF_UNSPEC; -+ nlreq.ifm.ifi_type = ARPHRD_NETROM; -+ nlreq.ifn.rta.rta_len = sizeof(nlreq.ifn); -+ nlreq.ifn.rta.rta_type = IFLA_IFNAME; -+ strlcpy(nlreq.ifn.ifname, req_ifname, sizeof(nlreq.ifn.ifname)); -+ nlreq.ifli.rta.rta_len = sizeof(nlreq.ifli); -+ nlreq.ifli.rta.rta_type = IFLA_LINKINFO; -+ nlreq.ifli.ifik.rta.rta_len = sizeof(nlreq.ifli.ifik); -+ nlreq.ifli.ifik.rta.rta_type = IFLA_INFO_KIND; -+ strcpy(nlreq.ifli.ifik.ifkind, "ppp"); -+ nlreq.ifli.ifid.rta.rta_len = sizeof(nlreq.ifli.ifid); -+ nlreq.ifli.ifid.rta.rta_type = IFLA_INFO_DATA; -+ nlreq.ifli.ifid.ifdata[0].rta.rta_len = sizeof(nlreq.ifli.ifid.ifdata[0]); -+ nlreq.ifli.ifid.ifdata[0].rta.rta_type = IFLA_PPP_DEV_FD; -+ nlreq.ifli.ifid.ifdata[0].ppp.ppp_dev_fd = ppp_dev_fd; -+ -+ memset(&nladdr, 0, sizeof(nladdr)); -+ nladdr.nl_family = AF_NETLINK; -+ -+ memset(&iov, 0, sizeof(iov)); -+ iov.iov_base = &nlreq; -+ iov.iov_len = sizeof(nlreq); -+ -+ memset(&msg, 0, sizeof(msg)); -+ msg.msg_name = &nladdr; -+ msg.msg_namelen = sizeof(nladdr); -+ msg.msg_iov = &iov; -+ msg.msg_iovlen = 1; -+ -+ if (sendmsg(fd, &msg, 0) < 0) { -+ error("make_ppp_unit_rtnetlink: sendmsg(RTM_NEWLINK/NLM_F_CREATE): %m (line %d)", __LINE__); -+ close(fd); -+ return 0; -+ } -+ -+ memset(&iov, 0, sizeof(iov)); -+ iov.iov_base = &nlresp; -+ iov.iov_len = sizeof(nlresp); -+ -+ memset(&msg, 0, sizeof(msg)); -+ msg.msg_name = &nladdr; -+ msg.msg_namelen = sizeof(nladdr); -+ msg.msg_iov = &iov; -+ msg.msg_iovlen = 1; -+ -+ nlresplen = recvmsg(fd, &msg, 0); -+ -+ if (nlresplen < 0) { -+ error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): %m (line %d)", __LINE__); -+ close(fd); -+ return 0; -+ } - -- memset(&nladdr, 0, sizeof(nladdr)); -- nladdr.nl_family = AF_NETLINK; -- -- if (bind(fd, (struct sockaddr *)&nladdr, sizeof(nladdr)) < 0) { -- error("make_ppp_unit_rtnetlink: bind(AF_NETLINK): %m (line %d)", __LINE__); - close(fd); -- return 0; -- } -- -- memset(&nlreq, 0, sizeof(nlreq)); -- nlreq.nlh.nlmsg_len = sizeof(nlreq); -- nlreq.nlh.nlmsg_type = RTM_NEWLINK; -- nlreq.nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_EXCL | NLM_F_CREATE; -- nlreq.ifm.ifi_family = AF_UNSPEC; -- nlreq.ifm.ifi_type = ARPHRD_NETROM; -- nlreq.ifn.rta.rta_len = sizeof(nlreq.ifn); -- nlreq.ifn.rta.rta_type = IFLA_IFNAME; -- strlcpy(nlreq.ifn.ifname, req_ifname, sizeof(nlreq.ifn.ifname)); -- nlreq.ifli.rta.rta_len = sizeof(nlreq.ifli); -- nlreq.ifli.rta.rta_type = IFLA_LINKINFO; -- nlreq.ifli.ifik.rta.rta_len = sizeof(nlreq.ifli.ifik); -- nlreq.ifli.ifik.rta.rta_type = IFLA_INFO_KIND; -- strcpy(nlreq.ifli.ifik.ifkind, "ppp"); -- nlreq.ifli.ifid.rta.rta_len = sizeof(nlreq.ifli.ifid); -- nlreq.ifli.ifid.rta.rta_type = IFLA_INFO_DATA; -- nlreq.ifli.ifid.ifdata[0].rta.rta_len = sizeof(nlreq.ifli.ifid.ifdata[0]); -- nlreq.ifli.ifid.ifdata[0].rta.rta_type = IFLA_PPP_DEV_FD; -- nlreq.ifli.ifid.ifdata[0].ppp.ppp_dev_fd = ppp_dev_fd; -- -- memset(&nladdr, 0, sizeof(nladdr)); -- nladdr.nl_family = AF_NETLINK; -- -- memset(&iov, 0, sizeof(iov)); -- iov.iov_base = &nlreq; -- iov.iov_len = sizeof(nlreq); -- -- memset(&msg, 0, sizeof(msg)); -- msg.msg_name = &nladdr; -- msg.msg_namelen = sizeof(nladdr); -- msg.msg_iov = &iov; -- msg.msg_iovlen = 1; -- -- if (sendmsg(fd, &msg, 0) < 0) { -- error("make_ppp_unit_rtnetlink: sendmsg(RTM_NEWLINK/NLM_F_CREATE): %m (line %d)", __LINE__); -- close(fd); -- return 0; -- } -- -- memset(&iov, 0, sizeof(iov)); -- iov.iov_base = &nlresp; -- iov.iov_len = sizeof(nlresp); -- -- memset(&msg, 0, sizeof(msg)); -- msg.msg_name = &nladdr; -- msg.msg_namelen = sizeof(nladdr); -- msg.msg_iov = &iov; -- msg.msg_iovlen = 1; -- -- nlresplen = recvmsg(fd, &msg, 0); -- -- if (nlresplen < 0) { -- error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): %m (line %d)", __LINE__); -- close(fd); -- return 0; -- } -- -- close(fd); - -- if (nladdr.nl_family != AF_NETLINK) { -- error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): Not a netlink packet (line %d)", __LINE__); -- return 0; -- } -- -- if ((size_t)nlresplen < sizeof(nlresp) || nlresp.nlh.nlmsg_len < sizeof(nlresp)) { -- error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): Acknowledgment netlink packet too short (line %d)", __LINE__); -- return 0; -- } -- -- /* acknowledgment packet for NLM_F_ACK is NLMSG_ERROR */ -- if (nlresp.nlh.nlmsg_type != NLMSG_ERROR) { -- error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): Not an acknowledgment netlink packet (line %d)", __LINE__); -- return 0; -- } -+ if (nladdr.nl_family != AF_NETLINK) { -+ error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): Not a netlink packet (line %d)", __LINE__); -+ return 0; -+ } -+ -+ if ((size_t)nlresplen < sizeof(nlresp) || nlresp.nlh.nlmsg_len < sizeof(nlresp)) { -+ error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): Acknowledgment netlink packet too short (line %d)", __LINE__); -+ return 0; -+ } -+ -+ /* acknowledgment packet for NLM_F_ACK is NLMSG_ERROR */ -+ if (nlresp.nlh.nlmsg_type != NLMSG_ERROR) { -+ error("make_ppp_unit_rtnetlink: recvmsg(NLM_F_ACK): Not an acknowledgment netlink packet (line %d)", __LINE__); -+ return 0; -+ } -+ } while (nlresp.nlerr.error == -EBUSY); - - /* error == 0 indicates success, negative value is errno code */ - if (nlresp.nlerr.error != 0) { diff --git a/package/network/services/ppp/patches/200-makefile.patch b/package/network/services/ppp/patches/200-makefile.patch deleted file mode 100644 index d0b9a9a99b..0000000000 --- a/package/network/services/ppp/patches/200-makefile.patch +++ /dev/null @@ -1,56 +0,0 @@ -pppd: tune Linux config defaults for OpenWrt - -This patch adjusts a number defaults to properly match the OpenWrt environment. -It is not intended for upstream. - -Signed-off-by: Jo-Philipp Wich - ---- a/pppd/Makefile.linux -+++ b/pppd/Makefile.linux -@@ -49,7 +49,7 @@ MPPE=y - # Uncomment the next line to include support for PPP packet filtering. - # This requires that the libpcap library and headers be installed - # and that the kernel driver support PPP packet filtering. --FILTER=y -+#FILTER=y - - # Uncomment the next line to enable multilink PPP (enabled by default) - # Linux distributions: Please leave multilink ENABLED in your builds -@@ -59,7 +59,7 @@ HAVE_MULTILINK=y - # Uncomment the next line to enable the TDB database (enabled by default.) - # If you enable multilink, then TDB is automatically enabled also. - # Linux distributions: Please leave TDB ENABLED in your builds. --USE_TDB=y -+#USE_TDB=y - - # Uncomment the next line to enable Type=notify services in systemd - # If enabled, and the user sets the up_sdnotify option, then -@@ -85,13 +85,13 @@ USE_LIBUTIL=y - endif - - # Enable EAP-TLS authentication (requires MPPE support, libssl and libcrypto) --USE_EAPTLS=y -+#USE_EAPTLS=y - - MAXOCTETS=y - - INCLUDE_DIRS= -I../include - --COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP -pipe -+COMPILE_FLAGS= -DHAVE_PATHS_H -DHAVE_MMAP -pipe - - CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS) '-DDESTDIR="@DESTDIR@"' - -@@ -143,10 +143,10 @@ CFLAGS += -DHAS_SHADOW - #LIBS += -lshadow $(LIBS) - endif - --ifeq ($(shell echo '\#include ' | $(CC) -E - >/dev/null 2>&1 && echo yes),yes) -+#ifeq ($(shell echo '\#include ' | $(CC) -E - >/dev/null 2>&1 && echo yes),yes) - CFLAGS += -DHAVE_CRYPT_H=1 - LIBS += -lcrypt --endif -+#endif - - ifdef USE_LIBUTIL - CFLAGS += -DHAVE_LOGWTMP=1 diff --git a/package/network/services/ppp/patches/201-mppe_mppc_1.1.patch b/package/network/services/ppp/patches/201-mppe_mppc_1.1.patch deleted file mode 100644 index 3c30517e42..0000000000 --- a/package/network/services/ppp/patches/201-mppe_mppc_1.1.patch +++ /dev/null @@ -1,1518 +0,0 @@ -pppd: add support for MPPE and MPPC encryption and compression protocols - -This is a forward ported version of ppp-2.4.3-mppe-mppc-1.1.patch.gz found on -http://mppe-mppc.alphacron.de/ . - -Signed-off-by: Jo-Philipp Wich - ---- a/include/linux/ppp-comp.h -+++ b/include/linux/ppp-comp.h -@@ -36,7 +36,7 @@ - */ - - /* -- * ==FILEVERSION 20020319== -+ * ==FILEVERSION 20020715== - * - * NOTE TO MAINTAINERS: - * If you modify this file at all, please set the above date. -@@ -201,6 +201,33 @@ struct compressor { - #define CI_MPPE 18 /* config option for MPPE */ - #define CILEN_MPPE 6 /* length of config option */ - -+/* MPPE/MPPC definitions by J.D.*/ -+#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */ -+#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */ -+#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */ -+#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */ -+#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */ -+ -+/* -+ * Definitions for Stac LZS. -+ */ -+ -+#define CI_LZS 17 /* config option for Stac LZS */ -+#define CILEN_LZS 5 /* length of config option */ -+ -+#define LZS_OVHD 4 /* max. LZS overhead */ -+#define LZS_HIST_LEN 2048 /* LZS history size */ -+#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */ -+ -+#define LZS_MODE_NONE 0 -+#define LZS_MODE_LCB 1 -+#define LZS_MODE_CRC 2 -+#define LZS_MODE_SEQ 3 -+#define LZS_MODE_EXT 4 -+ -+#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */ -+#define LZS_EXT_BIT_COMP 0x20 /* bit C */ -+ - /* - * Definitions for other, as yet unsupported, compression methods. - */ ---- a/include/net/ppp-comp.h -+++ b/include/net/ppp-comp.h -@@ -168,6 +168,33 @@ struct compressor { - #define CI_MPPE 18 /* config option for MPPE */ - #define CILEN_MPPE 6 /* length of config option */ - -+/* MPPE/MPPC definitions by J.D.*/ -+#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */ -+#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */ -+#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */ -+#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */ -+#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */ -+ -+/* -+ * Definitions for Stac LZS. -+ */ -+ -+#define CI_LZS 17 /* config option for Stac LZS */ -+#define CILEN_LZS 5 /* length of config option */ -+ -+#define LZS_OVHD 4 /* max. LZS overhead */ -+#define LZS_HIST_LEN 2048 /* LZS history size */ -+#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */ -+ -+#define LZS_MODE_NONE 0 -+#define LZS_MODE_LCB 1 -+#define LZS_MODE_CRC 2 -+#define LZS_MODE_SEQ 3 -+#define LZS_MODE_EXT 4 -+ -+#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */ -+#define LZS_EXT_BIT_COMP 0x20 /* bit C */ -+ - /* - * Definitions for other, as yet unsupported, compression methods. - */ ---- a/pppd/ccp.c -+++ b/pppd/ccp.c -@@ -61,12 +61,10 @@ static int setdeflate (char **); - static char bsd_value[8]; - static char deflate_value[8]; - --/* -- * Option variables. -- */ - #ifdef MPPE --bool refuse_mppe_stateful = 1; /* Allow stateful mode? */ --#endif -+static int setmppe(char **); -+static int setnomppe(void); -+#endif /* MPPE */ - - static option_t ccp_option_list[] = { - { "noccp", o_bool, &ccp_protent.enabled_flag, -@@ -107,54 +105,36 @@ static option_t ccp_option_list[] = { - "don't allow Predictor-1", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR, - &ccp_allowoptions[0].predictor_1 }, - -+ { "lzs", o_bool, &ccp_wantoptions[0].lzs, -+ "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_PRIO }, -+ { "+lzs", o_bool, &ccp_wantoptions[0].lzs, -+ "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_ALIAS | OPT_PRIO }, -+ { "nolzs", o_bool, &ccp_wantoptions[0].lzs, -+ "don't allow Stac LZS", OPT_PRIOSUB | OPT_A2CLR, -+ &ccp_allowoptions[0].lzs }, -+ { "-lzs", o_bool, &ccp_wantoptions[0].lzs, -+ "don't allow Stac LZS", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR, -+ &ccp_allowoptions[0].lzs }, -+ - #ifdef MPPE -- /* MPPE options are symmetrical ... we only set wantoptions here */ -- { "require-mppe", o_bool, &ccp_wantoptions[0].mppe, -- "require MPPE encryption", -- OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 }, -- { "+mppe", o_bool, &ccp_wantoptions[0].mppe, -- "require MPPE encryption", -- OPT_ALIAS | OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 }, -- { "nomppe", o_bool, &ccp_wantoptions[0].mppe, -- "don't allow MPPE encryption", OPT_PRIO }, -- { "-mppe", o_bool, &ccp_wantoptions[0].mppe, -- "don't allow MPPE encryption", OPT_ALIAS | OPT_PRIO }, -- -- /* We use ccp_allowoptions[0].mppe as a junk var ... it is reset later */ -- { "require-mppe-40", o_bool, &ccp_allowoptions[0].mppe, -- "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40, -- &ccp_wantoptions[0].mppe }, -- { "+mppe-40", o_bool, &ccp_allowoptions[0].mppe, -- "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40, -- &ccp_wantoptions[0].mppe }, -- { "nomppe-40", o_bool, &ccp_allowoptions[0].mppe, -- "don't allow MPPE 40-bit encryption", -- OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40, &ccp_wantoptions[0].mppe }, -- { "-mppe-40", o_bool, &ccp_allowoptions[0].mppe, -- "don't allow MPPE 40-bit encryption", -- OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40, -- &ccp_wantoptions[0].mppe }, -- -- { "require-mppe-128", o_bool, &ccp_allowoptions[0].mppe, -- "require MPPE 128-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_128, -- &ccp_wantoptions[0].mppe }, -- { "+mppe-128", o_bool, &ccp_allowoptions[0].mppe, -- "require MPPE 128-bit encryption", -- OPT_ALIAS | OPT_PRIO | OPT_A2OR | MPPE_OPT_128, -- &ccp_wantoptions[0].mppe }, -- { "nomppe-128", o_bool, &ccp_allowoptions[0].mppe, -- "don't allow MPPE 128-bit encryption", -- OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128, &ccp_wantoptions[0].mppe }, -- { "-mppe-128", o_bool, &ccp_allowoptions[0].mppe, -- "don't allow MPPE 128-bit encryption", -- OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128, -- &ccp_wantoptions[0].mppe }, -- -- /* strange one; we always request stateless, but will we allow stateful? */ -- { "mppe-stateful", o_bool, &refuse_mppe_stateful, -- "allow MPPE stateful mode", OPT_PRIO }, -- { "nomppe-stateful", o_bool, &refuse_mppe_stateful, -- "disallow MPPE stateful mode", OPT_PRIO | 1 }, -+ { "mppc", o_bool, &ccp_wantoptions[0].mppc, -+ "request MPPC compression", 1, &ccp_allowoptions[0].mppc }, -+ { "+mppc", o_bool, &ccp_wantoptions[0].mppc, -+ "request MPPC compression", 1, &ccp_allowoptions[0].mppc, OPT_ALIAS }, -+ { "nomppc", o_bool, &ccp_wantoptions[0].mppc, -+ "don't allow MPPC compression", OPT_PRIOSUB | OPT_A2CLR, -+ &ccp_allowoptions[0].mppc }, -+ { "-mppc", o_bool, &ccp_wantoptions[0].mppc, -+ "don't allow MPPC compression", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR, -+ &ccp_allowoptions[0].mppc }, -+ { "mppe", o_special, (void *)setmppe, -+ "request MPPE encryption" }, -+ { "+mppe", o_special, (void *)setmppe, -+ "request MPPE encryption" }, -+ { "nomppe", o_special_noarg, (void *)setnomppe, -+ "don't allow MPPE encryption" }, -+ { "-mppe", o_special_noarg, (void *)setnomppe, -+ "don't allow MPPE encryption" }, - #endif /* MPPE */ - - { NULL } -@@ -240,7 +220,7 @@ static fsm_callbacks ccp_callbacks = { - */ - #define ANY_COMPRESS(opt) ((opt).deflate || (opt).bsd_compress \ - || (opt).predictor_1 || (opt).predictor_2 \ -- || (opt).mppe) -+ || (opt).lzs || (opt).mppc || (opt).mppe) - - /* - * Local state (mainly for handling reset-reqs and reset-acks). -@@ -341,6 +321,100 @@ setdeflate(char **argv) - return 1; - } - -+#ifdef MPPE -+/* -+ * Functions called from config options -+ */ -+/* -+ MPPE suboptions: -+ required - require MPPE; disconnect if peer doesn't support it -+ stateless - use stateless mode -+ no40 - disable 40 bit keys -+ no56 - disable 56 bit keys -+ no128 - disable 128 bit keys -+*/ -+int setmppe(char **argv) -+{ -+ int i; -+ char *str, cmdbuf[16]; -+ -+ ccp_allowoptions[0].mppe = 1; -+ ccp_allowoptions[0].mppe_40 = 1; -+ ccp_allowoptions[0].mppe_56 = 1; -+ ccp_allowoptions[0].mppe_128 = 1; -+ ccp_allowoptions[0].mppe_stateless = 0; -+ ccp_wantoptions[0].mppe = 0; -+ -+ str = *argv; -+ -+ while (1) { -+ i = 0; -+ memset(cmdbuf, '\0', 16); -+ while ((i < 16) && (*str != ',') && (*str != '\0')) -+ cmdbuf[i++] = *str++; -+ cmdbuf[i] = '\0'; -+ if (!strncasecmp(cmdbuf, "no40", strlen("no40"))) { -+ ccp_allowoptions[0].mppe_40 = 0; -+ goto next_param; -+ } else if (!strncasecmp(cmdbuf, "no56", strlen("no56"))) { -+ ccp_allowoptions[0].mppe_56 = 0; -+ goto next_param; -+ } else if (!strncasecmp(cmdbuf, "no128", strlen("no128"))) { -+ ccp_allowoptions[0].mppe_128 = 0; -+ goto next_param; -+ } else if (!strncasecmp(cmdbuf, "stateless", strlen("stateless"))) { -+ ccp_allowoptions[0].mppe_stateless = 1; -+ goto next_param; -+ } else if (!strncasecmp(cmdbuf, "required", strlen("required"))) { -+ ccp_wantoptions[0].mppe = 1; -+ goto next_param; -+ } else { -+ option_error("invalid parameter '%s' for mppe option", cmdbuf); -+ return 0; -+ } -+ -+ next_param: -+ if (*str == ',') { -+ str++; -+ continue; -+ } -+ if (*str == '\0') { -+ if (!(ccp_allowoptions[0].mppe_40 || ccp_allowoptions[0].mppe_56 || -+ ccp_allowoptions[0].mppe_128)) { -+ if (ccp_wantoptions[0].mppe == 1) { -+ option_error("You require MPPE but you have switched off " -+ "all encryption key lengths."); -+ return 0; -+ } -+ ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0; -+ ccp_wantoptions[0].mppe_stateless = -+ ccp_allowoptions[0].mppe_stateless = 0; -+ } else { -+ ccp_allowoptions[0].mppe = 1; -+ ccp_wantoptions[0].mppe_stateless = -+ ccp_allowoptions[0].mppe_stateless; -+ if (ccp_wantoptions[0].mppe == 1) { -+ ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40; -+ ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56; -+ ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128; -+ } -+ } -+ return 1; -+ } -+ } -+} -+ -+int setnomppe(void) -+{ -+ ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0; -+ ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40 = 0; -+ ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56 = 0; -+ ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128 = 0; -+ ccp_wantoptions[0].mppe_stateless = ccp_allowoptions[0].mppe_stateless = 0; -+ return 1; -+} -+#endif /* MPPE */ -+ - /* - * ccp_init - initialize CCP. - */ -@@ -374,6 +448,30 @@ ccp_init(int unit) - ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS; - - ccp_allowoptions[0].predictor_1 = 1; -+ -+ ccp_wantoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */ -+ ccp_wantoptions[0].lzs_mode = LZS_MODE_SEQ; -+ ccp_wantoptions[0].lzs_hists = 1; -+ ccp_allowoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */ -+ ccp_allowoptions[0].lzs_mode = LZS_MODE_SEQ; -+ ccp_allowoptions[0].lzs_hists = 1; -+ -+#ifdef MPPE -+ /* by default allow and request MPPC... */ -+ ccp_wantoptions[0].mppc = ccp_allowoptions[0].mppc = 1; -+ -+ /* ... and allow but don't request MPPE */ -+ ccp_allowoptions[0].mppe = 1; -+ ccp_allowoptions[0].mppe_40 = 1; -+ ccp_allowoptions[0].mppe_56 = 1; -+ ccp_allowoptions[0].mppe_128 = 1; -+ ccp_allowoptions[0].mppe_stateless = 1; -+ ccp_wantoptions[0].mppe = 0; -+ ccp_wantoptions[0].mppe_40 = 0; -+ ccp_wantoptions[0].mppe_56 = 0; -+ ccp_wantoptions[0].mppe_128 = 0; -+ ccp_wantoptions[0].mppe_stateless = 0; -+#endif /* MPPE */ - } - - /* -@@ -443,11 +541,11 @@ ccp_input(int unit, u_char *p, int len) - if (oldstate == OPENED && p[0] == TERMREQ && f->state != OPENED) { - notice("Compression disabled by peer."); - #ifdef MPPE -- if (ccp_gotoptions[unit].mppe) { -+ if (ccp_wantoptions[unit].mppe) { - error("MPPE disabled, closing LCP"); - lcp_close(unit, "MPPE disabled by peer"); - } --#endif -+#endif /* MPPE */ - } - - /* -@@ -471,6 +569,15 @@ ccp_extcode(fsm *f, int code, int id, u_ - break; - /* send a reset-ack, which the transmitter will see and - reset its compression state. */ -+ -+ /* In case of MPPE/MPPC or LZS we shouldn't send CCP_RESETACK, -+ but we do it in order to reset compressor; CCP_RESETACK is -+ then silently discarded. See functions ppp_send_frame and -+ ppp_ccp_peek in ppp_generic.c (Linux only !!!). All the -+ confusion is caused by the fact that CCP code is splited -+ into two parts - one part is handled by pppd, the other one -+ is handled by kernel. */ -+ - fsm_sdata(f, CCP_RESETACK, id, NULL, 0); - break; - -@@ -498,12 +605,11 @@ ccp_protrej(int unit) - fsm_lowerdown(&ccp_fsm[unit]); - - #ifdef MPPE -- if (ccp_gotoptions[unit].mppe) { -+ if (ccp_wantoptions[unit].mppe) { - error("MPPE required but peer negotiation failed"); - lcp_close(unit, "MPPE required but peer negotiation failed"); - } --#endif -- -+#endif /* MPPE */ - } - - /* -@@ -519,7 +625,7 @@ ccp_resetci(fsm *f) - all_rejected[f->unit] = 0; - - #ifdef MPPE -- if (go->mppe) { -+ if (go->mppe || go->mppc) { - ccp_options *ao = &ccp_allowoptions[f->unit]; - int auth_mschap_bits = auth_done[f->unit]; - #ifdef USE_EAPTLS -@@ -536,95 +642,124 @@ ccp_resetci(fsm *f) - * NB: If MPPE is required, all other compression opts are invalid. - * So, we return right away if we can't do it. - */ -- -- /* Leave only the mschap auth bits set */ -- auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER | -- CHAP_MS2_WITHPEER | CHAP_MS2_PEER); -- /* Count the mschap auths */ -- auth_mschap_bits >>= CHAP_MS_SHIFT; -- numbits = 0; -- do { -- numbits += auth_mschap_bits & 1; -- auth_mschap_bits >>= 1; -- } while (auth_mschap_bits); -- if (numbits > 1) { -- error("MPPE required, but auth done in both directions."); -- lcp_close(f->unit, "MPPE required but not available"); -- return; -- } -+ if (ccp_wantoptions[f->unit].mppe) { -+ /* Leave only the mschap auth bits set */ -+ auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER | -+ CHAP_MS2_WITHPEER | CHAP_MS2_PEER); -+ /* Count the mschap auths */ -+ auth_mschap_bits >>= CHAP_MS_SHIFT; -+ numbits = 0; -+ do { -+ numbits += auth_mschap_bits & 1; -+ auth_mschap_bits >>= 1; -+ } while (auth_mschap_bits); -+ if (numbits > 1) { -+ error("MPPE required, but auth done in both directions."); -+ lcp_close(f->unit, "MPPE required but not available"); -+ return; -+ } - - #ifdef USE_EAPTLS -- /* -- * MPPE is also possible in combination with EAP-TLS. -- * It is not possible to detect if we're doing EAP or EAP-TLS -- * at this stage, hence we accept all forms of EAP. If TLS is -- * not used then the MPPE keys will not be derived anyway. -- */ -- /* Leave only the eap auth bits set */ -- auth_eap_bits &= (EAP_WITHPEER | EAP_PEER ); -+ /* -+ * MPPE is also possible in combination with EAP-TLS. -+ * It is not possible to detect if we're doing EAP or EAP-TLS -+ * at this stage, hence we accept all forms of EAP. If TLS is -+ * not used then the MPPE keys will not be derived anyway. -+ */ -+ /* Leave only the eap auth bits set */ -+ auth_eap_bits &= (EAP_WITHPEER | EAP_PEER ); - -- if ((numbits == 0) && (auth_eap_bits == 0)) { -- error("MPPE required, but MS-CHAP[v2] nor EAP-TLS auth are performed."); -+ if ((numbits == 0) && (auth_eap_bits == 0)) { -+ error("MPPE required, but MS-CHAP[v2] nor EAP-TLS auth are performed."); - #else -- if (!numbits) { -- error("MPPE required, but MS-CHAP[v2] auth not performed."); -+ if (!numbits) { -+ error("MPPE required, but MS-CHAP[v2] auth not performed."); - #endif -- lcp_close(f->unit, "MPPE required but not available"); -- return; -- } -+ lcp_close(f->unit, "MPPE required but not available"); -+ return; -+ } - -- /* A plugin (eg radius) may not have obtained key material. */ -- if (!mppe_keys_set) { -- error("MPPE required, but keys are not available. " -- "Possible plugin problem?"); -- lcp_close(f->unit, "MPPE required but not available"); -- return; -- } -- -- /* LM auth not supported for MPPE */ -- if (auth_done[f->unit] & (CHAP_MS_WITHPEER | CHAP_MS_PEER)) { -- /* This might be noise */ -- if (go->mppe & MPPE_OPT_40) { -- notice("Disabling 40-bit MPPE; MS-CHAP LM not supported"); -- go->mppe &= ~MPPE_OPT_40; -- ccp_wantoptions[f->unit].mppe &= ~MPPE_OPT_40; -+ /* A plugin (eg radius) may not have obtained key material. */ -+ if (!mppe_keys_set) { -+ error("MPPE required, but keys are not available. " -+ "Possible plugin problem?"); -+ lcp_close(f->unit, "MPPE required but not available"); -+ return; - } - } - -- /* Last check: can we actually negotiate something? */ -- if (!(go->mppe & (MPPE_OPT_40 | MPPE_OPT_128))) { -- /* Could be misconfig, could be 40-bit disabled above. */ -- error("MPPE required, but both 40-bit and 128-bit disabled."); -- lcp_close(f->unit, "MPPE required but not available"); -- return; -+ /* -+ * Check whether the kernel knows about the various -+ * compression methods we might request. Key material -+ * unimportant here. -+ */ -+ if (go->mppc) { -+ opt_buf[0] = CI_MPPE; -+ opt_buf[1] = CILEN_MPPE; -+ opt_buf[2] = 0; -+ opt_buf[3] = 0; -+ opt_buf[4] = 0; -+ opt_buf[5] = MPPE_MPPC; -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 0) <= 0) -+ go->mppc = 0; -+ } -+ if (go->mppe_40) { -+ opt_buf[0] = CI_MPPE; -+ opt_buf[1] = CILEN_MPPE; -+ opt_buf[2] = MPPE_STATELESS; -+ opt_buf[3] = 0; -+ opt_buf[4] = 0; -+ opt_buf[5] = MPPE_40BIT; -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0) -+ go->mppe_40 = 0; -+ } -+ if (go->mppe_56) { -+ opt_buf[0] = CI_MPPE; -+ opt_buf[1] = CILEN_MPPE; -+ opt_buf[2] = MPPE_STATELESS; -+ opt_buf[3] = 0; -+ opt_buf[4] = 0; -+ opt_buf[5] = MPPE_56BIT; -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0) -+ go->mppe_56 = 0; -+ } -+ if (go->mppe_128) { -+ opt_buf[0] = CI_MPPE; -+ opt_buf[1] = CILEN_MPPE; -+ opt_buf[2] = MPPE_STATELESS; -+ opt_buf[3] = 0; -+ opt_buf[4] = 0; -+ opt_buf[5] = MPPE_128BIT; -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0) -+ go->mppe_128 = 0; -+ } -+ if (!go->mppe_40 && !go->mppe_56 && !go->mppe_128) { -+ if (ccp_wantoptions[f->unit].mppe) { -+ error("MPPE required, but kernel has no support."); -+ lcp_close(f->unit, "MPPE required but not available"); -+ } -+ go->mppe = go->mppe_stateless = 0; -+ } else { -+ /* MPPE is not compatible with other compression types */ -+ if (ccp_wantoptions[f->unit].mppe) { -+ ao->bsd_compress = go->bsd_compress = 0; -+ ao->predictor_1 = go->predictor_1 = 0; -+ ao->predictor_2 = go->predictor_2 = 0; -+ ao->deflate = go->deflate = 0; -+ ao->lzs = go->lzs = 0; -+ } - } -- -- /* sync options */ -- ao->mppe = go->mppe; -- /* MPPE is not compatible with other compression types */ -- ao->bsd_compress = go->bsd_compress = 0; -- ao->predictor_1 = go->predictor_1 = 0; -- ao->predictor_2 = go->predictor_2 = 0; -- ao->deflate = go->deflate = 0; - } - #endif /* MPPE */ -- -- /* -- * Check whether the kernel knows about the various -- * compression methods we might request. -- */ --#ifdef MPPE -- if (go->mppe) { -- opt_buf[0] = CI_MPPE; -- opt_buf[1] = CILEN_MPPE; -- MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]); -- /* Key material unimportant here. */ -- if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0) { -- error("MPPE required, but kernel has no support."); -- lcp_close(f->unit, "MPPE required but not available"); -- } -+ if (go->lzs) { -+ opt_buf[0] = CI_LZS; -+ opt_buf[1] = CILEN_LZS; -+ opt_buf[2] = go->lzs_hists >> 8; -+ opt_buf[3] = go->lzs_hists & 0xff; -+ opt_buf[4] = LZS_MODE_SEQ; -+ if (ccp_test(f->unit, opt_buf, CILEN_LZS, 0) <= 0) -+ go->lzs = 0; - } --#endif - if (go->bsd_compress) { - opt_buf[0] = CI_BSD_COMPRESS; - opt_buf[1] = CILEN_BSD_COMPRESS; -@@ -679,7 +814,8 @@ static int - + (go->deflate && go->deflate_draft? CILEN_DEFLATE: 0) - + (go->predictor_1? CILEN_PREDICTOR_1: 0) - + (go->predictor_2? CILEN_PREDICTOR_2: 0) -- + (go->mppe? CILEN_MPPE: 0); -+ + (go->lzs? CILEN_LZS: 0) -+ + ((go->mppe || go->mppc)? CILEN_MPPE: 0); - } - - /* -@@ -690,6 +826,8 @@ static void - { - int res; - ccp_options *go = &ccp_gotoptions[f->unit]; -+ ccp_options *ao = &ccp_allowoptions[f->unit]; -+ ccp_options *wo = &ccp_wantoptions[f->unit]; - u_char *p0 = p; - - /* -@@ -698,22 +836,43 @@ static void - * in case it gets Acked. - */ - #ifdef MPPE -- if (go->mppe) { -+ if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) { - u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN]; - -- p[0] = opt_buf[0] = CI_MPPE; -- p[1] = opt_buf[1] = CILEN_MPPE; -- MPPE_OPTS_TO_CI(go->mppe, &p[2]); -- MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]); -+ p[0] = CI_MPPE; -+ p[1] = CILEN_MPPE; -+ p[2] = (go->mppe_stateless ? MPPE_STATELESS : 0); -+ p[3] = 0; -+ p[4] = 0; -+ p[5] = (go->mppe_40 ? MPPE_40BIT : 0) | (go->mppe_56 ? MPPE_56BIT : 0) | -+ (go->mppe_128 ? MPPE_128BIT : 0) | (go->mppc ? MPPE_MPPC : 0); -+ -+ BCOPY(p, opt_buf, CILEN_MPPE); - BCOPY(mppe_recv_key, &opt_buf[CILEN_MPPE], MPPE_MAX_KEY_LEN); - res = ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0); -- if (res > 0) -+ if (res > 0) { - p += CILEN_MPPE; -- else -+ } else { - /* This shouldn't happen, we've already tested it! */ -- lcp_close(f->unit, "MPPE required but not available in kernel"); -+ go->mppe = go->mppe_40 = go->mppe_56 = go->mppe_128 = -+ go->mppe_stateless = go->mppc = 0; -+ if (ccp_wantoptions[f->unit].mppe) -+ lcp_close(f->unit, "MPPE required but not available in kernel"); -+ } -+ } -+#endif /* MPPE */ -+ if (go->lzs) { -+ p[0] = CI_LZS; -+ p[1] = CILEN_LZS; -+ p[2] = go->lzs_hists >> 8; -+ p[3] = go->lzs_hists & 0xff; -+ p[4] = LZS_MODE_SEQ; -+ res = ccp_test(f->unit, p, CILEN_LZS, 0); -+ if (res > 0) { -+ p += CILEN_LZS; -+ } else -+ go->lzs = 0; - } --#endif - if (go->deflate) { - p[0] = go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT; - p[1] = CILEN_DEFLATE; -@@ -799,30 +958,50 @@ static void - - /* - * ccp_ackci - process a received configure-ack, and return -- * 1 iff the packet was OK. -+ * 1 if the packet was OK. - */ - static int - ccp_ackci(fsm *f, u_char *p, int len) - { - ccp_options *go = &ccp_gotoptions[f->unit]; -+ ccp_options *ao = &ccp_allowoptions[f->unit]; -+ ccp_options *wo = &ccp_wantoptions[f->unit]; - u_char *p0 = p; - - #ifdef MPPE -- if (go->mppe) { -- u_char opt_buf[CILEN_MPPE]; -- -- opt_buf[0] = CI_MPPE; -- opt_buf[1] = CILEN_MPPE; -- MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]); -- if (len < CILEN_MPPE || memcmp(opt_buf, p, CILEN_MPPE)) -+ if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) { -+ if (len < CILEN_MPPE -+ || p[1] != CILEN_MPPE || p[0] != CI_MPPE -+ || p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0) -+ || p[3] != 0 -+ || p[4] != 0 -+ || (p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) | -+ (go->mppc ? MPPE_MPPC : 0)) -+ && p[5] != ((go->mppe_56 ? MPPE_56BIT : 0) | -+ (go->mppc ? MPPE_MPPC : 0)) -+ && p[5] != ((go->mppe_128 ? MPPE_128BIT : 0) | -+ (go->mppc ? MPPE_MPPC : 0)))) - return 0; -+ if (go->mppe_40 || go->mppe_56 || go->mppe_128) -+ go->mppe = 1; - p += CILEN_MPPE; - len -= CILEN_MPPE; -+ /* Cope with first/fast ack */ -+ if (p == p0 && len == 0) -+ return 1; -+ } -+#endif /* MPPE */ -+ if (go->lzs) { -+ if (len < CILEN_LZS || p[0] != CI_LZS || p[1] != CILEN_LZS -+ || p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff) -+ || p[4] != LZS_MODE_SEQ) -+ return 0; -+ p += CILEN_LZS; -+ len -= CILEN_LZS; - /* XXX Cope with first/fast ack */ -- if (len == 0) -+ if (p == p0 && len == 0) - return 1; - } --#endif - if (go->deflate) { - if (len < CILEN_DEFLATE - || p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT) -@@ -891,6 +1070,8 @@ static int - ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) - { - ccp_options *go = &ccp_gotoptions[f->unit]; -+ ccp_options *ao = &ccp_allowoptions[f->unit]; -+ ccp_options *wo = &ccp_wantoptions[f->unit]; - ccp_options no; /* options we've seen already */ - ccp_options try; /* options to ask for next time */ - -@@ -898,28 +1079,100 @@ static int - try = *go; - - #ifdef MPPE -- if (go->mppe && len >= CILEN_MPPE -- && p[0] == CI_MPPE && p[1] == CILEN_MPPE) { -- no.mppe = 1; -- /* -- * Peer wants us to use a different strength or other setting. -- * Fail if we aren't willing to use his suggestion. -- */ -- MPPE_CI_TO_OPTS(&p[2], try.mppe); -- if ((try.mppe & MPPE_OPT_STATEFUL) && refuse_mppe_stateful) { -- error("Refusing MPPE stateful mode offered by peer"); -- try.mppe = 0; -- } else if (((go->mppe | MPPE_OPT_STATEFUL) & try.mppe) != try.mppe) { -- /* Peer must have set options we didn't request (suggest) */ -- try.mppe = 0; -- } -+ if ((go->mppe || go->mppc || (!wo->mppe && ao->mppe)) && -+ len >= CILEN_MPPE && p[0] == CI_MPPE && p[1] == CILEN_MPPE) { - -- if (!try.mppe) { -- error("MPPE required but peer negotiation failed"); -- lcp_close(f->unit, "MPPE required but peer negotiation failed"); -+ if (go->mppc) { -+ no.mppc = 1; -+ if (!(p[5] & MPPE_MPPC)) -+ try.mppc = 0; -+ } -+ -+ if (go->mppe) -+ no.mppe = 1; -+ if (go->mppe_40) -+ no.mppe_40 = 1; -+ if (go->mppe_56) -+ no.mppe_56 = 1; -+ if (go->mppe_128) -+ no.mppe_128 = 1; -+ if (go->mppe_stateless) -+ no.mppe_stateless = 1; -+ -+ if (ao->mppe_40) { -+ if ((p[5] & MPPE_40BIT)) -+ try.mppe_40 = 1; -+ else -+ try.mppe_40 = (p[5] == 0) ? 1 : 0; -+ } -+ if (ao->mppe_56) { -+ if ((p[5] & MPPE_56BIT)) -+ try.mppe_56 = 1; -+ else -+ try.mppe_56 = (p[5] == 0) ? 1 : 0; -+ } -+ if (ao->mppe_128) { -+ if ((p[5] & MPPE_128BIT)) -+ try.mppe_128 = 1; -+ else -+ try.mppe_128 = (p[5] == 0) ? 1 : 0; -+ } -+ -+ if (ao->mppe_stateless) { -+ if ((p[2] & MPPE_STATELESS) || wo->mppe_stateless) -+ try.mppe_stateless = 1; -+ else -+ try.mppe_stateless = 0; -+ } -+ -+ if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128) { -+ try.mppe = try.mppe_stateless = 0; -+ if (wo->mppe) { -+ /* we require encryption, but peer doesn't support it -+ so we close connection */ -+ wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 = -+ wo->mppe_56 = wo->mppe_128 = 0; -+ lcp_close(f->unit, "MPPE required but cannot negotiate MPPE " -+ "key length"); -+ } -+ } -+ if (wo->mppe && (wo->mppe_40 != try.mppe_40) && -+ (wo->mppe_56 != try.mppe_56) && (wo->mppe_128 != try.mppe_128)) { -+ /* cannot negotiate key length */ -+ wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 = -+ wo->mppe_56 = wo->mppe_128 = 0; -+ lcp_close(f->unit, "Cannot negotiate MPPE key length"); - } -+ if (try.mppe_40 && try.mppe_56 && try.mppe_128) -+ try.mppe_40 = try.mppe_56 = 0; -+ else -+ if (try.mppe_56 && try.mppe_128) -+ try.mppe_56 = 0; -+ else -+ if (try.mppe_40 && try.mppe_128) -+ try.mppe_40 = 0; -+ else -+ if (try.mppe_40 && try.mppe_56) -+ try.mppe_40 = 0; -+ -+ p += CILEN_MPPE; -+ len -= CILEN_MPPE; - } - #endif /* MPPE */ -+ -+ if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) { -+ no.lzs = 1; -+ if (((p[2]<<8)|p[3]) > 1 || (p[4] != LZS_MODE_SEQ && -+ p[4] != LZS_MODE_EXT)) -+ try.lzs = 0; -+ else { -+ try.lzs_mode = p[4]; -+ try.lzs_hists = (p[2] << 8) | p[3]; -+ } -+ p += CILEN_LZS; -+ len -= CILEN_LZS; -+ } -+ - if (go->deflate && len >= CILEN_DEFLATE - && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT) - && p[1] == CILEN_DEFLATE) { -@@ -989,14 +1242,50 @@ ccp_rejci(fsm *f, u_char *p, int len) - return -1; - - #ifdef MPPE -- if (go->mppe && len >= CILEN_MPPE -+ if ((go->mppe || go->mppc) && len >= CILEN_MPPE - && p[0] == CI_MPPE && p[1] == CILEN_MPPE) { -- error("MPPE required but peer refused"); -- lcp_close(f->unit, "MPPE required but peer refused"); -+ ccp_options *wo = &ccp_wantoptions[f->unit]; -+ if (p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0) || -+ p[3] != 0 || -+ p[4] != 0 || -+ p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) | -+ (go->mppe_56 ? MPPE_56BIT : 0) | -+ (go->mppe_128 ? MPPE_128BIT : 0) | -+ (go->mppc ? MPPE_MPPC : 0))) -+ return 0; -+ if (go->mppc) -+ try.mppc = 0; -+ if (go->mppe) { -+ try.mppe = 0; -+ if (go->mppe_40) -+ try.mppe_40 = 0; -+ if (go->mppe_56) -+ try.mppe_56 = 0; -+ if (go->mppe_128) -+ try.mppe_128 = 0; -+ if (go->mppe_stateless) -+ try.mppe_stateless = 0; -+ if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128) -+ try.mppe = try.mppe_stateless = 0; -+ if (wo->mppe) { /* we want MPPE but cannot negotiate key length */ -+ wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 = -+ wo->mppe_56 = wo->mppe_128 = 0; -+ lcp_close(f->unit, "MPPE required but cannot negotiate MPPE " -+ "key length"); -+ } -+ } - p += CILEN_MPPE; - len -= CILEN_MPPE; - } --#endif -+#endif /* MPPE */ -+ if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) { -+ if (p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff) -+ || p[4] != go->lzs_mode) -+ return 0; -+ try.lzs = 0; -+ p += CILEN_LZS; -+ len -= CILEN_LZS; -+ } - if (go->deflate_correct && len >= CILEN_DEFLATE - && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) { - if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size) -@@ -1056,14 +1345,15 @@ static int - ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) - { - int ret, newret, res; -- u_char *p0, *retp; -+ u_char *p0, *retp, p2, p5; - int len, clen, type, nb; - ccp_options *ho = &ccp_hisoptions[f->unit]; - ccp_options *ao = &ccp_allowoptions[f->unit]; -+ ccp_options *wo = &ccp_wantoptions[f->unit]; - #ifdef MPPE -- bool rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */ -- /* CI_MPPE, or due to other options? */ --#endif -+ u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN]; -+/* int mtu; */ -+#endif /* MPPE */ - - ret = CONFACK; - retp = p0 = p; -@@ -1086,106 +1376,302 @@ ccp_reqci(fsm *f, u_char *p, int *lenp, - switch (type) { - #ifdef MPPE - case CI_MPPE: -- if (!ao->mppe || clen != CILEN_MPPE) { -+ if ((!ao->mppc && !ao->mppe) || clen != CILEN_MPPE) { - newret = CONFREJ; - break; - } -- MPPE_CI_TO_OPTS(&p[2], ho->mppe); -- -- /* Nak if anything unsupported or unknown are set. */ -- if (ho->mppe & MPPE_OPT_UNSUPPORTED) { -+ p2 = p[2]; -+ p5 = p[5]; -+ /* not sure what they want, tell 'em what we got */ -+ if (((p[2] & ~MPPE_STATELESS) != 0 || p[3] != 0 || p[4] != 0 || -+ (p[5] & ~(MPPE_40BIT | MPPE_56BIT | MPPE_128BIT | -+ MPPE_MPPC)) != 0 || p[5] == 0) || -+ (p[2] == 0 && p[3] == 0 && p[4] == 0 && p[5] == 0)) { - newret = CONFNAK; -- ho->mppe &= ~MPPE_OPT_UNSUPPORTED; -- } -- if (ho->mppe & MPPE_OPT_UNKNOWN) { -- newret = CONFNAK; -- ho->mppe &= ~MPPE_OPT_UNKNOWN; -- } -- -- /* Check state opt */ -- if (ho->mppe & MPPE_OPT_STATEFUL) { -- /* -- * We can Nak and request stateless, but it's a -- * lot easier to just assume the peer will request -- * it if he can do it; stateful mode is bad over -- * the Internet -- which is where we expect MPPE. -- */ -- if (refuse_mppe_stateful) { -- error("Refusing MPPE stateful mode offered by peer"); -- newret = CONFREJ; -- break; -+ p[2] = (wo->mppe_stateless ? MPPE_STATELESS : 0); -+ p[3] = 0; -+ p[4] = 0; -+ p[5] = (wo->mppe_40 ? MPPE_40BIT : 0) | -+ (wo->mppe_56 ? MPPE_56BIT : 0) | -+ (wo->mppe_128 ? MPPE_128BIT : 0) | -+ (wo->mppc ? MPPE_MPPC : 0); -+ break; -+ } -+ -+ if ((p[5] & MPPE_MPPC)) { -+ if (ao->mppc) { -+ ho->mppc = 1; -+ BCOPY(p, opt_buf, CILEN_MPPE); -+ opt_buf[2] = opt_buf[3] = opt_buf[4] = 0; -+ opt_buf[5] = MPPE_MPPC; -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 1) <= 0) { -+ ho->mppc = 0; -+ p[5] &= ~MPPE_MPPC; -+ newret = CONFNAK; -+ } -+ } else { -+ newret = CONFREJ; -+ if (wo->mppe || ao->mppe) { -+ p[5] &= ~MPPE_MPPC; -+ newret = CONFNAK; -+ } - } - } -- -- /* Find out which of {S,L} are set. */ -- if ((ho->mppe & MPPE_OPT_128) -- && (ho->mppe & MPPE_OPT_40)) { -- /* Both are set, negotiate the strongest. */ -- newret = CONFNAK; -- if (ao->mppe & MPPE_OPT_128) -- ho->mppe &= ~MPPE_OPT_40; -- else if (ao->mppe & MPPE_OPT_40) -- ho->mppe &= ~MPPE_OPT_128; -- else { -- newret = CONFREJ; -- break; -- } -- } else if (ho->mppe & MPPE_OPT_128) { -- if (!(ao->mppe & MPPE_OPT_128)) { -- newret = CONFREJ; -- break; -- } -- } else if (ho->mppe & MPPE_OPT_40) { -- if (!(ao->mppe & MPPE_OPT_40)) { -- newret = CONFREJ; -- break; -- } -+ if (ao->mppe) -+ ho->mppe = 1; -+ -+ if ((p[2] & MPPE_STATELESS)) { -+ if (ao->mppe_stateless) { -+ if (wo->mppe_stateless) -+ ho->mppe_stateless = 1; -+ else { -+ newret = CONFNAK; -+ if (!dont_nak) -+ p[2] &= ~MPPE_STATELESS; -+ } -+ } else { -+ newret = CONFNAK; -+ if (!dont_nak) -+ p[2] &= ~MPPE_STATELESS; -+ } -+ } else { -+ if (wo->mppe_stateless && !dont_nak) { -+ wo->mppe_stateless = 0; -+ newret = CONFNAK; -+ p[2] |= MPPE_STATELESS; -+ } -+ } -+ -+ if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT|MPPE_128BIT)) { -+ newret = CONFNAK; -+ if (ao->mppe_128) { -+ ho->mppe_128 = 1; -+ p[5] &= ~(MPPE_40BIT|MPPE_56BIT); -+ BCOPY(p, opt_buf, CILEN_MPPE); -+ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE], -+ MPPE_MAX_KEY_LEN); -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + -+ MPPE_MAX_KEY_LEN, 1) <= 0) { -+ ho->mppe_128 = 0; -+ p[5] |= (MPPE_40BIT|MPPE_56BIT); -+ p[5] &= ~MPPE_128BIT; -+ goto check_mppe_56_40; -+ } -+ goto check_mppe; -+ } -+ p[5] &= ~MPPE_128BIT; -+ goto check_mppe_56_40; -+ } -+ if ((p[5] & ~MPPE_MPPC) == (MPPE_56BIT|MPPE_128BIT)) { -+ newret = CONFNAK; -+ if (ao->mppe_128) { -+ ho->mppe_128 = 1; -+ p[5] &= ~MPPE_56BIT; -+ BCOPY(p, opt_buf, CILEN_MPPE); -+ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE], -+ MPPE_MAX_KEY_LEN); -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + -+ MPPE_MAX_KEY_LEN, 1) <= 0) { -+ ho->mppe_128 = 0; -+ p[5] |= MPPE_56BIT; -+ p[5] &= ~MPPE_128BIT; -+ goto check_mppe_56; -+ } -+ goto check_mppe; -+ } -+ p[5] &= ~MPPE_128BIT; -+ goto check_mppe_56; -+ } -+ if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_128BIT)) { -+ newret = CONFNAK; -+ if (ao->mppe_128) { -+ ho->mppe_128 = 1; -+ p[5] &= ~MPPE_40BIT; -+ BCOPY(p, opt_buf, CILEN_MPPE); -+ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE], -+ MPPE_MAX_KEY_LEN); -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + -+ MPPE_MAX_KEY_LEN, 1) <= 0) { -+ ho->mppe_128 = 0; -+ p[5] |= MPPE_40BIT; -+ p[5] &= ~MPPE_128BIT; -+ goto check_mppe_40; -+ } -+ goto check_mppe; -+ } -+ p[5] &= ~MPPE_128BIT; -+ goto check_mppe_40; -+ } -+ if ((p[5] & ~MPPE_MPPC) == MPPE_128BIT) { -+ if (ao->mppe_128) { -+ ho->mppe_128 = 1; -+ BCOPY(p, opt_buf, CILEN_MPPE); -+ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE], -+ MPPE_MAX_KEY_LEN); -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + -+ MPPE_MAX_KEY_LEN, 1) <= 0) { -+ ho->mppe_128 = 0; -+ p[5] &= ~MPPE_128BIT; -+ newret = CONFNAK; -+ } -+ goto check_mppe; -+ } -+ p[5] &= ~MPPE_128BIT; -+ newret = CONFNAK; -+ goto check_mppe; -+ } -+ check_mppe_56_40: -+ if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT)) { -+ newret = CONFNAK; -+ if (ao->mppe_56) { -+ ho->mppe_56 = 1; -+ p[5] &= ~MPPE_40BIT; -+ BCOPY(p, opt_buf, CILEN_MPPE); -+ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE], -+ MPPE_MAX_KEY_LEN); -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + -+ MPPE_MAX_KEY_LEN, 1) <= 0) { -+ ho->mppe_56 = 0; -+ p[5] |= MPPE_40BIT; -+ p[5] &= ~MPPE_56BIT; -+ newret = CONFNAK; -+ goto check_mppe_40; -+ } -+ goto check_mppe; -+ } -+ p[5] &= ~MPPE_56BIT; -+ goto check_mppe_40; -+ } -+ check_mppe_56: -+ if ((p[5] & ~MPPE_MPPC) == MPPE_56BIT) { -+ if (ao->mppe_56) { -+ ho->mppe_56 = 1; -+ BCOPY(p, opt_buf, CILEN_MPPE); -+ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE], -+ MPPE_MAX_KEY_LEN); -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + -+ MPPE_MAX_KEY_LEN, 1) <= 0) { -+ ho->mppe_56 = 0; -+ p[5] &= ~MPPE_56BIT; -+ newret = CONFNAK; -+ } -+ goto check_mppe; -+ } -+ p[5] &= ~MPPE_56BIT; -+ newret = CONFNAK; -+ goto check_mppe; -+ } -+ check_mppe_40: -+ if ((p[5] & ~MPPE_MPPC) == MPPE_40BIT) { -+ if (ao->mppe_40) { -+ ho->mppe_40 = 1; -+ BCOPY(p, opt_buf, CILEN_MPPE); -+ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE], -+ MPPE_MAX_KEY_LEN); -+ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + -+ MPPE_MAX_KEY_LEN, 1) <= 0) { -+ ho->mppe_40 = 0; -+ p[5] &= ~MPPE_40BIT; -+ newret = CONFNAK; -+ } -+ goto check_mppe; -+ } -+ p[5] &= ~MPPE_40BIT; -+ } -+ -+ check_mppe: -+ if (!ho->mppe_40 && !ho->mppe_56 && !ho->mppe_128) { -+ if (wo->mppe_40 || wo->mppe_56 || wo->mppe_128) { -+ newret = CONFNAK; -+ p[2] |= (wo->mppe_stateless ? MPPE_STATELESS : 0); -+ p[5] |= (wo->mppe_40 ? MPPE_40BIT : 0) | -+ (wo->mppe_56 ? MPPE_56BIT : 0) | -+ (wo->mppe_128 ? MPPE_128BIT : 0) | -+ (wo->mppc ? MPPE_MPPC : 0); -+ } else { -+ ho->mppe = ho->mppe_stateless = 0; -+ } - } else { -- /* Neither are set. */ -- /* We cannot accept this. */ -- newret = CONFNAK; -- /* Give the peer our idea of what can be used, -- so it can choose and confirm */ -- ho->mppe = ao->mppe; -- } -- -- /* rebuild the opts */ -- MPPE_OPTS_TO_CI(ho->mppe, &p[2]); -- if (newret == CONFACK) { -- u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN]; -- int mtu; -- -- BCOPY(p, opt_buf, CILEN_MPPE); -- BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE], -- MPPE_MAX_KEY_LEN); -- if (ccp_test(f->unit, opt_buf, -- CILEN_MPPE + MPPE_MAX_KEY_LEN, 1) <= 0) { -- /* This shouldn't happen, we've already tested it! */ -- error("MPPE required, but kernel has no support."); -- lcp_close(f->unit, "MPPE required but not available"); -- newret = CONFREJ; -- break; -- } -- /* -- * We need to decrease the interface MTU by MPPE_PAD -- * because MPPE frames **grow**. The kernel [must] -- * allocate MPPE_PAD extra bytes in xmit buffers. -- */ -- mtu = netif_get_mtu(f->unit); -- if (mtu) -- netif_set_mtu(f->unit, mtu - MPPE_PAD); -- else -- newret = CONFREJ; -- } -- -- /* -- * We have accepted MPPE or are willing to negotiate -- * MPPE parameters. A CONFREJ is due to subsequent -- * (non-MPPE) processing. -- */ -- rej_for_ci_mppe = 0; -- break; --#endif /* MPPE */ -+ /* MPPE is not compatible with other compression types */ -+ if (wo->mppe) { -+ ao->bsd_compress = 0; -+ ao->predictor_1 = 0; -+ ao->predictor_2 = 0; -+ ao->deflate = 0; -+ ao->lzs = 0; -+ } -+ } -+ if ((!ho->mppc || !ao->mppc) && !ho->mppe) { -+ p[2] = p2; -+ p[5] = p5; -+ newret = CONFREJ; -+ break; -+ } -+ -+ /* -+ * I have commented the code below because according to RFC1547 -+ * MTU is only information for higher level protocols about -+ * "the maximum allowable length for a packet (q.v.) transmitted -+ * over a point-to-point link without incurring network layer -+ * fragmentation." Of course a PPP implementation should be able -+ * to handle overhead added by MPPE - in our case apropriate code -+ * is located in drivers/net/ppp_generic.c in the kernel sources. -+ * -+ * According to RFC1661: -+ * - when negotiated MRU is less than 1500 octets, a PPP -+ * implementation must still be able to receive at least 1500 -+ * octets, -+ * - when PFC is negotiated, a PPP implementation is still -+ * required to receive frames with uncompressed protocol field. -+ * -+ * So why not to handle MPPE overhead without changing MTU value? -+ * I am sure that RFC3078, unfortunately silently, assumes that. -+ */ -+ -+ /* -+ * We need to decrease the interface MTU by MPPE_PAD -+ * because MPPE frames **grow**. The kernel [must] -+ * allocate MPPE_PAD extra bytes in xmit buffers. -+ */ -+ /* -+ mtu = netif_get_mtu(f->unit); -+ if (mtu) { -+ netif_set_mtu(f->unit, mtu - MPPE_PAD); -+ } else { -+ newret = CONFREJ; -+ if (ccp_wantoptions[f->unit].mppe) { -+ error("Cannot adjust MTU needed by MPPE."); -+ lcp_close(f->unit, "Cannot adjust MTU needed by MPPE."); -+ } -+ } -+ */ -+ break; -+ #endif /* MPPE */ -+ -+ case CI_LZS: -+ if (!ao->lzs || clen != CILEN_LZS) { -+ newret = CONFREJ; -+ break; -+ } -+ -+ ho->lzs = 1; -+ ho->lzs_hists = (p[2] << 8) | p[3]; -+ ho->lzs_mode = p[4]; -+ if ((ho->lzs_hists != ao->lzs_hists) || -+ (ho->lzs_mode != ao->lzs_mode)) { -+ newret = CONFNAK; -+ if (!dont_nak) { -+ p[2] = ao->lzs_hists >> 8; -+ p[3] = ao->lzs_hists & 0xff; -+ p[4] = ao->lzs_mode; -+ } else -+ break; -+ } -+ -+ if (p == p0 && ccp_test(f->unit, p, CILEN_LZS, 1) <= 0) { -+ newret = CONFREJ; -+ } -+ break; - case CI_DEFLATE: - case CI_DEFLATE_DRAFT: - if (!ao->deflate || clen != CILEN_DEFLATE -@@ -1327,12 +1813,6 @@ ccp_reqci(fsm *f, u_char *p, int *lenp, - else - *lenp = retp - p0; - } --#ifdef MPPE -- if (ret == CONFREJ && ao->mppe && rej_for_ci_mppe) { -- error("MPPE required but peer negotiation failed"); -- lcp_close(f->unit, "MPPE required but peer negotiation failed"); -- } --#endif - return ret; - } - -@@ -1353,24 +1833,35 @@ method_name(ccp_options *opt, ccp_option - char *p = result; - char *q = result + sizeof(result); /* 1 past result */ - -- slprintf(p, q - p, "MPPE "); -- p += 5; -- if (opt->mppe & MPPE_OPT_128) { -- slprintf(p, q - p, "128-bit "); -- p += 8; -- } -- if (opt->mppe & MPPE_OPT_40) { -- slprintf(p, q - p, "40-bit "); -- p += 7; -- } -- if (opt->mppe & MPPE_OPT_STATEFUL) -- slprintf(p, q - p, "stateful"); -- else -- slprintf(p, q - p, "stateless"); -- -+ if (opt->mppe) { -+ if (opt->mppc) { -+ slprintf(p, q - p, "MPPC/MPPE "); -+ p += 10; -+ } else { -+ slprintf(p, q - p, "MPPE "); -+ p += 5; -+ } -+ if (opt->mppe_128) { -+ slprintf(p, q - p, "128-bit "); -+ p += 8; -+ } else if (opt->mppe_56) { -+ slprintf(p, q - p, "56-bit "); -+ p += 7; -+ } else if (opt->mppe_40) { -+ slprintf(p, q - p, "40-bit "); -+ p += 7; -+ } -+ if (opt->mppe_stateless) -+ slprintf(p, q - p, "stateless"); -+ else -+ slprintf(p, q - p, "stateful"); -+ } else if (opt->mppc) -+ slprintf(p, q - p, "MPPC"); - break; - } --#endif -+#endif /* MPPE */ -+ case CI_LZS: -+ return "Stac LZS"; - case CI_DEFLATE: - case CI_DEFLATE_DRAFT: - if (opt2 != NULL && opt2->deflate_size != opt->deflate_size) -@@ -1425,12 +1916,12 @@ ccp_up(fsm *f) - } else if (ANY_COMPRESS(*ho)) - notice("%s transmit compression enabled", method_name(ho, NULL)); - #ifdef MPPE -- if (go->mppe) { -+ if (go->mppe || go->mppc) { - BZERO(mppe_recv_key, MPPE_MAX_KEY_LEN); - BZERO(mppe_send_key, MPPE_MAX_KEY_LEN); - continue_networks(f->unit); /* Bring up IP et al */ - } --#endif -+#endif /* MPPE */ - } - - /* -@@ -1452,7 +1943,7 @@ ccp_down(fsm *f) - lcp_close(f->unit, "MPPE disabled"); - } - } --#endif -+#endif /* MPPE */ - } - - /* -@@ -1509,24 +2000,28 @@ ccp_printpkt(u_char *p, int plen, - #ifdef MPPE - case CI_MPPE: - if (optlen >= CILEN_MPPE) { -- u_char mppe_opts; -- -- MPPE_CI_TO_OPTS(&p[2], mppe_opts); -- printer(arg, "mppe %s %s %s %s %s %s%s", -- (p[2] & MPPE_H_BIT)? "+H": "-H", -- (p[5] & MPPE_M_BIT)? "+M": "-M", -- (p[5] & MPPE_S_BIT)? "+S": "-S", -- (p[5] & MPPE_L_BIT)? "+L": "-L", -+ printer(arg, "mppe %s %s %s %s %s %s", -+ (p[2] & MPPE_STATELESS)? "+H": "-H", -+ (p[5] & MPPE_56BIT)? "+M": "-M", -+ (p[5] & MPPE_128BIT)? "+S": "-S", -+ (p[5] & MPPE_40BIT)? "+L": "-L", - (p[5] & MPPE_D_BIT)? "+D": "-D", -- (p[5] & MPPE_C_BIT)? "+C": "-C", -- (mppe_opts & MPPE_OPT_UNKNOWN)? " +U": ""); -- if (mppe_opts & MPPE_OPT_UNKNOWN) -+ (p[5] & MPPE_MPPC)? "+C": "-C"); -+ if ((p[5] & ~(MPPE_56BIT | MPPE_128BIT | MPPE_40BIT | -+ MPPE_D_BIT | MPPE_MPPC)) || -+ (p[2] & ~MPPE_STATELESS)) - printer(arg, " (%.2x %.2x %.2x %.2x)", - p[2], p[3], p[4], p[5]); - p += CILEN_MPPE; - } - break; --#endif -+#endif /* MPPE */ -+ case CI_LZS: -+ if (optlen >= CILEN_LZS) { -+ printer(arg, "lzs %.2x %.2x %.2x", p[2], p[3], p[4]); -+ p += CILEN_LZS; -+ } -+ break; - case CI_DEFLATE: - case CI_DEFLATE_DRAFT: - if (optlen >= CILEN_DEFLATE) { -@@ -1609,6 +2104,7 @@ ccp_datainput(int unit, u_char *pkt, int - error("Lost compression sync: disabling compression"); - ccp_close(unit, "Lost compression sync"); - #ifdef MPPE -+ /* My module dosn't need this. J.D., 2003-07-06 */ - /* - * If we were doing MPPE, we must also take the link down. - */ -@@ -1616,9 +2112,18 @@ ccp_datainput(int unit, u_char *pkt, int - error("Too many MPPE errors, closing LCP"); - lcp_close(unit, "Too many MPPE errors"); - } --#endif -+#endif /* MPPE */ - } else { - /* -+ * When LZS or MPPE/MPPC is negotiated we just send CCP_RESETREQ -+ * and don't wait for CCP_RESETACK -+ */ -+ if ((ccp_gotoptions[f->unit].method == CI_LZS) || -+ (ccp_gotoptions[f->unit].method == CI_MPPE)) { -+ fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0); -+ return; -+ } -+ /* - * Send a reset-request to reset the peer's compressor. - * We don't do that if we are still waiting for an - * acknowledgement to a previous reset-request. ---- a/pppd/ccp.h -+++ b/pppd/ccp.h -@@ -37,9 +37,17 @@ typedef struct ccp_options { - bool predictor_2; /* do Predictor-2? */ - bool deflate_correct; /* use correct code for deflate? */ - bool deflate_draft; /* use draft RFC code for deflate? */ -+ bool lzs; /* do Stac LZS? */ -+ bool mppc; /* do MPPC? */ - u_char mppe; /* MPPE bitfield */ -+ bool mppe_40; /* allow 40 bit encryption? */ -+ bool mppe_56; /* allow 56 bit encryption? */ -+ bool mppe_128; /* allow 128 bit encryption? */ -+ bool mppe_stateless; /* allow stateless encryption */ - u_short bsd_bits; /* # bits/code for BSD Compress */ - u_short deflate_size; /* lg(window size) for Deflate */ -+ u_short lzs_mode; /* LZS check mode */ -+ u_short lzs_hists; /* number of LZS histories */ - short method; /* code for chosen compression method */ - } ccp_options; - ---- a/pppd/chap_ms.c -+++ b/pppd/chap_ms.c -@@ -964,13 +964,17 @@ set_mppe_enc_types(int policy, int types - /* - * Disable undesirable encryption types. Note that we don't ENABLE - * any encryption types, to avoid overriding manual configuration. -+ * -+ * It seems that 56 bit keys are unsupported in MS-RADIUS (see RFC 2548) - */ - switch(types) { - case MPPE_ENC_TYPES_RC4_40: -- ccp_wantoptions[0].mppe &= ~MPPE_OPT_128; /* disable 128-bit */ -+ ccp_wantoptions[0].mppe_128 = 0; /* disable 128-bit */ -+ ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */ - break; - case MPPE_ENC_TYPES_RC4_128: -- ccp_wantoptions[0].mppe &= ~MPPE_OPT_40; /* disable 40-bit */ -+ ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */ -+ ccp_wantoptions[0].mppe_40 = 0; /* disable 40-bit */ - break; - default: - break; diff --git a/package/network/services/ppp/patches/203-opt_flags.patch b/package/network/services/ppp/patches/203-opt_flags.patch deleted file mode 100644 index 705959e7ba..0000000000 --- a/package/network/services/ppp/patches/203-opt_flags.patch +++ /dev/null @@ -1,38 +0,0 @@ -build: Move optimization flags into a separate variable - -Isolate optimization related compiler flags from CFLAGS and move them into a -separate COPTS variable so that it is easier to override optimizations from -the environment. - -Signed-off-by: Jo-Philipp Wich - ---- a/pppd/plugins/radius/Makefile.linux -+++ b/pppd/plugins/radius/Makefile.linux -@@ -47,13 +47,13 @@ install: all - $(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR) - - radius.so: radius.o libradiusclient.a -- $(CC) $(LDFLAGS) -o radius.so -shared radius.o libradiusclient.a -+ $(CC) $(LDFLAGS) -fPIC -o radius.so -shared radius.o libradiusclient.a - - radattr.so: radattr.o -- $(CC) $(LDFLAGS) -o radattr.so -shared radattr.o -+ $(CC) $(LDFLAGS) -fPIC -o radattr.so -shared radattr.o - - radrealms.so: radrealms.o -- $(CC) $(LDFLAGS) -o radrealms.so -shared radrealms.o -+ $(CC) $(LDFLAGS) -fPIC -o radrealms.so -shared radrealms.o - - CLIENTOBJS = avpair.o buildreq.o config.o dict.o ip_util.o \ - clientid.o sendserver.o lock.o util.o md5.o ---- a/pppd/plugins/pppoe/Makefile.linux -+++ b/pppd/plugins/pppoe/Makefile.linux -@@ -38,7 +38,7 @@ debug.o: debug.c - $(CC) $(CFLAGS) -I../../.. -c -o debug.o debug.c - - pppoe.so: plugin.o discovery.o if.o common.o -- $(CC) $(LDFLAGS) -o pppoe.so -shared plugin.o discovery.o if.o common.o -+ $(CC) $(LDFLAGS) -fPIC -o pppoe.so -shared plugin.o discovery.o if.o common.o - - install: all - $(INSTALL) -d -m 755 $(LIBDIR) diff --git a/package/network/services/ppp/patches/204-radius_config.patch b/package/network/services/ppp/patches/204-radius_config.patch index 2f30b9d3dc..3f6db59b71 100644 --- a/package/network/services/ppp/patches/204-radius_config.patch +++ b/package/network/services/ppp/patches/204-radius_config.patch @@ -1,6 +1,6 @@ --- a/pppd/plugins/radius/config.c +++ b/pppd/plugins/radius/config.c -@@ -371,31 +371,37 @@ static int test_config(char *filename) +@@ -381,31 +381,37 @@ static int test_config(char *filename) } #endif diff --git a/package/network/services/ppp/patches/205-no_exponential_timeout.patch b/package/network/services/ppp/patches/205-no_exponential_timeout.patch deleted file mode 100644 index b08c2eff89..0000000000 --- a/package/network/services/ppp/patches/205-no_exponential_timeout.patch +++ /dev/null @@ -1,29 +0,0 @@ -pppd: Don't use exponential timeout in discovery phase - -This patch removes the exponential timeout increase between PADO or PADS -discovery attempts. - -Signed-off-by: Jo-Philipp Wich - ---- a/pppd/plugins/pppoe/discovery.c -+++ b/pppd/plugins/pppoe/discovery.c -@@ -632,7 +632,9 @@ discovery(PPPoEConnection *conn) - conn->discoveryState = STATE_SENT_PADI; - waitForPADO(conn, timeout); - -+#if 0 - timeout *= 2; -+#endif - } while (conn->discoveryState == STATE_SENT_PADI); - - timeout = conn->discoveryTimeout; -@@ -647,7 +649,9 @@ discovery(PPPoEConnection *conn) - sendPADR(conn); - conn->discoveryState = STATE_SENT_PADR; - waitForPADS(conn, timeout); -+#if 0 - timeout *= 2; -+#endif - } while (conn->discoveryState == STATE_SENT_PADR); - - if (!conn->seenMaxPayload) { diff --git a/package/network/services/ppp/patches/207-lcp_mtu_max.patch b/package/network/services/ppp/patches/207-lcp_mtu_max.patch index 522576c627..3ca0534f36 100644 --- a/package/network/services/ppp/patches/207-lcp_mtu_max.patch +++ b/package/network/services/ppp/patches/207-lcp_mtu_max.patch @@ -8,18 +8,18 @@ Signed-off-by: Jo-Philipp Wich --- a/pppd/lcp.c +++ b/pppd/lcp.c -@@ -1862,12 +1862,12 @@ lcp_up(fsm *f) +@@ -1888,12 +1888,12 @@ lcp_up(fsm *f) * the interface MTU is set to the lowest of that, the * MTU we want to use, and our link MRU. */ - mtu = ho->neg_mru? ho->mru: PPP_MRU; + mtu = MIN(ho->neg_mru? ho->mru: PPP_MRU, ao->mru); mru = go->neg_mru? MAX(wo->mru, go->mru): PPP_MRU; - #ifdef HAVE_MULTILINK + #ifdef PPP_WITH_MULTILINK if (!(multilink && go->neg_mrru && ho->neg_mrru)) - #endif /* HAVE_MULTILINK */ -- netif_set_mtu(f->unit, MIN(MIN(mtu, mru), ao->mru)); -+ netif_set_mtu(f->unit, MIN(mtu, mru)); + #endif /* PPP_WITH_MULTILINK */ +- ppp_set_mtu(f->unit, MIN(MIN(mtu, mru), ao->mru)); ++ ppp_set_mtu(f->unit, MIN(mtu, mru)); ppp_send_config(f->unit, mtu, (ho->neg_asyncmap? ho->asyncmap: 0xffffffff), ho->neg_pcompression, ho->neg_accompression); diff --git a/package/network/services/ppp/patches/208-fix_status_code.patch b/package/network/services/ppp/patches/208-fix_status_code.patch index 1d991e7949..10cd945374 100644 --- a/package/network/services/ppp/patches/208-fix_status_code.patch +++ b/package/network/services/ppp/patches/208-fix_status_code.patch @@ -12,13 +12,13 @@ Signed-off-by: Jo-Philipp Wich --- a/pppd/main.c +++ b/pppd/main.c -@@ -1035,7 +1035,8 @@ get_input(void) +@@ -1152,7 +1152,8 @@ get_input(void) } notice("Modem hangup"); hungup = 1; -- status = EXIT_HANGUP; -+ if (status == EXIT_OK) -+ status = EXIT_HANGUP; +- code = EXIT_HANGUP; ++ if (code == EXIT_OK) ++ code = EXIT_HANGUP; lcp_lowerdown(0); /* serial link is no longer available */ link_terminated(0); return; diff --git a/package/network/services/ppp/patches/300-filter-pcap-includes-lib.patch b/package/network/services/ppp/patches/300-filter-pcap-includes-lib.patch deleted file mode 100644 index 87e340b3f1..0000000000 --- a/package/network/services/ppp/patches/300-filter-pcap-includes-lib.patch +++ /dev/null @@ -1,20 +0,0 @@ -build: Add required CFLAGS for libpcap - -This patch adds some flags to required to properly link libpcap within the -OpenWrt environment. - -Signed-off-by: Jo-Philipp Wich - ---- a/pppd/Makefile.linux -+++ b/pppd/Makefile.linux -@@ -210,8 +210,8 @@ LIBS += -ldl - endif - - ifdef FILTER --LIBS += -lpcap --CFLAGS += -DPPP_FILTER -+LIBS += -lpcap -L$(STAGING_DIR)/usr/lib -+CFLAGS += -DPPP_FILTER -I$(STAGING_DIR)/usr/include - endif - - ifdef HAVE_INET6 diff --git a/package/network/services/ppp/patches/310-precompile_filter.patch b/package/network/services/ppp/patches/310-precompile_filter.patch index ca91d153e9..ad0dd03de8 100644 --- a/package/network/services/ppp/patches/310-precompile_filter.patch +++ b/package/network/services/ppp/patches/310-precompile_filter.patch @@ -11,62 +11,70 @@ packets which are treated as active. Signed-off-by: Jo-Philipp Wich ---- a/pppd/Makefile.linux -+++ b/pppd/Makefile.linux -@@ -51,6 +51,9 @@ MPPE=y - # and that the kernel driver support PPP packet filtering. - #FILTER=y +--- a/configure.ac ++++ b/configure.ac +@@ -306,6 +306,9 @@ AM_CONDITIONAL(PPP_WITH_PAM, test "x${wi + # With libpcap support, activate pppd on network activity + AX_CHECK_PCAP -+# Support for precompiled filters -+PRECOMPILED_FILTER=y ++# internal statically linked pcap ++AM_CONDITIONAL(PPP_WITH_PRECOMPILED_FILTER, test "x${with_static_pcap}" = "xyes") + - # Uncomment the next line to enable multilink PPP (enabled by default) - # Linux distributions: Please leave multilink ENABLED in your builds - # of pppd! -@@ -214,6 +217,14 @@ LIBS += -lpcap -L$(STAGING_DIR)/usr/l - CFLAGS += -DPPP_FILTER -I$(STAGING_DIR)/usr/include + # + # SunOS provides a version of libpcap that would work, but SunOS has no support for activity filter + AM_CONDITIONAL([PPP_WITH_FILTER], [ test "x${with_pcap}" = "xyes" && test "x${build_sunos}" != "xyes" ]) +@@ -359,6 +362,7 @@ $PACKAGE_NAME version $PACKAGE_VERSION + With libatm..........: ${with_atm:-no} + With libpam..........: ${with_pam:-no} + With libpcap.........: ${with_pcap:-no} ++ With static libpcap..: ${with_static_pcap:-no} + With libsrp..........: ${with_srp:-no} + C Compiler...........: $CC $CFLAGS + Linker...............: $LD $LDFLAGS $LIBS +--- a/pppd/Makefile.am ++++ b/pppd/Makefile.am +@@ -138,6 +138,12 @@ pppd_LDFLAGS += $(PCAP_LDFLAGS) + pppd_LIBS += $(PCAP_LIBS) endif -+ifdef PRECOMPILED_FILTER -+PPPDSRCS += pcap_pcc.c -+HEADERS += pcap_pcc.h -+PPPDOBJS += pcap_pcc.o -+LIBS += $(STAGING_DIR)/usr/lib/libpcap.a -+CFLAGS += -DPPP_FILTER -DPPP_PRECOMPILED_FILTER -I$(STAGING_DIR)/usr/include ++if PPP_WITH_PRECOMPILED_FILTER ++pppd_SOURCES += pcap_pcc.c ++pppd_include_HEADERS += pcap_pcc.h ++pppd_LIBS += $(STAGING_DIR)/usr/lib/libpcap.a +endif + - ifdef HAVE_INET6 - PPPDSRCS += ipv6cp.c eui64.c - HEADERS += ipv6cp.h eui64.h + if PPP_WITH_PLUGINS + pppd_CPPFLAGS += -DPPPD_PLUGIN_DIR='"@PPPD_PLUGIN_DIR@"' + pppd_LIBS += -ldl --- a/pppd/options.c +++ b/pppd/options.c -@@ -56,6 +56,7 @@ +@@ -62,6 +62,7 @@ - #ifdef PPP_FILTER + #ifdef PPP_WITH_FILTER #include +#include /* * There have been 3 or 4 different names for this in libpcap CVS, but * this seems to be what they have settled on... -@@ -168,6 +169,13 @@ static int setlogfile(char **); +@@ -182,6 +183,13 @@ static int setlogfile(char **); static int loadplugin(char **); #endif -+#ifdef PPP_PRECOMPILED_FILTER ++#ifdef PPP_WITH_PRECOMPILED_FILTER +#include "pcap_pcc.h" +static int setprecompiledpassfilter(char **); +static int setprecompiledactivefilter(char **); -+#undef PPP_FILTER ++#undef PPP_WITH_FILTER +#endif + - #ifdef PPP_FILTER + #ifdef PPP_WITH_FILTER static int setpassfilter(char **); static int setactivefilter(char **); -@@ -360,6 +368,14 @@ option_t general_options[] = { +@@ -391,6 +399,14 @@ struct option general_options[] = { "set filter for active pkts", OPT_PRIO }, #endif -+#ifdef PPP_PRECOMPILED_FILTER ++#ifdef PPP_WITH_PRECOMPILED_FILTER + { "precompiled-pass-filter", 1, setprecompiledpassfilter, + "set precompiled filter for packets to pass", OPT_PRIO }, + @@ -74,14 +82,14 @@ Signed-off-by: Jo-Philipp Wich + "set precompiled filter for active pkts", OPT_PRIO }, +#endif + - #ifdef MAXOCTETS { "maxoctets", o_int, &maxoctets, "Set connection traffic limit", -@@ -1468,6 +1484,27 @@ callfile(char **argv) + OPT_PRIO | OPT_LLIMIT | OPT_NOINCR | OPT_ZEROINF }, +@@ -1666,6 +1682,27 @@ callfile(char **argv) return ok; } -+#ifdef PPP_PRECOMPILED_FILTER ++#ifdef PPP_WITH_PRECOMPILED_FILTER +/* + * setprecompiledpassfilter - Set the pass filter for packets using a + * precompiled expression @@ -102,18 +110,19 @@ Signed-off-by: Jo-Philipp Wich +} +#endif + - #ifdef PPP_FILTER + #ifdef PPP_WITH_FILTER /* * setpassfilter - Set the pass filter for packets --- /dev/null +++ b/pppd/pcap_pcc.c -@@ -0,0 +1,74 @@ +@@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include ++#include "options.h" +#include "pppd.h" + +int pcap_pre_compiled (char * fname, struct bpf_program *p) @@ -123,7 +132,7 @@ Signed-off-by: Jo-Philipp Wich + FILE *f = fopen (fname, "r"); + if (!f) + { -+ option_error("error opening precompiled active-filter '%s': %s", ++ ppp_option_error("error opening precompiled active-filter '%s': %s", + fname, strerror (errno)); + return 0; + } @@ -167,18 +176,18 @@ Signed-off-by: Jo-Philipp Wich + } + if (size != index) + { -+ option_error("error in precompiled active-filter," -+ " expected %d expressions, got %dn", -+ size, index); ++ ppp_option_error("error in precompiled active-filter," ++ " expected %d expressions, got %dn", ++ size, index); + ret = 0; + } + fclose(f); + return ret; + +err: -+ option_error("error in precompiled active-filter" -+ " expression line %s:%d (wrong size)\n", -+ fname, line); ++ ppp_option_error("error in precompiled active-filter" ++ " expression line %s:%d (wrong size)\n", ++ fname, line); + fclose (f); + return 0; +} diff --git a/package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch b/package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch index 0ae84ae1ed..a761ca650d 100644 --- a/package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch +++ b/package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch @@ -8,15 +8,15 @@ Signed-off-by: George Kashperko 2 files changed, 53 insertions(+), 14 deletions(-) --- a/pppd/multilink.c +++ b/pppd/multilink.c -@@ -35,6 +35,7 @@ +@@ -40,6 +40,7 @@ #include #include #include +#include - #include "pppd.h" + #include "pppd-private.h" #include "fsm.h" -@@ -56,7 +57,8 @@ static void iterate_bundle_links(void (* +@@ -62,7 +63,8 @@ static void iterate_bundle_links(void (* static int get_default_epdisc(struct epdisc *); static int parse_num(char *str, const char *key, int *valp); @@ -26,7 +26,7 @@ Signed-off-by: George Kashperko #define set_ip_epdisc(ep, addr) do { \ ep->length = 4; \ -@@ -197,35 +199,38 @@ mp_join_bundle(void) +@@ -215,35 +217,38 @@ mp_join_bundle(void) key.dptr = bundle_id; key.dsize = p - bundle_id; pid = tdb_fetch(pppdb, key); @@ -61,7 +61,7 @@ Signed-off-by: George Kashperko - if (bundle_attach(unit)) { + if (unit >= 0 && bundle_attach(unit)) { set_ifunit(0); - script_setenv("BUNDLE", bundle_id + 7, 0); + ppp_script_setenv("BUNDLE", bundle_id + 7, 0); make_bundle_links(1); unlock_db(); - info("Link attached to %s", ifname); @@ -73,7 +73,7 @@ Signed-off-by: George Kashperko } /* we have to make a new bundle */ -@@ -405,20 +410,39 @@ parse_num(char *str, const char *key, in +@@ -423,20 +428,39 @@ parse_num(char *str, const char *key, in return 0; } @@ -119,7 +119,7 @@ Signed-off-by: George Kashperko && memcmp(vd.dptr, key.dptr, vd.dsize) == 0; --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c -@@ -923,6 +923,16 @@ void cfg_bundle(int mrru, int mtru, int +@@ -984,6 +984,16 @@ void cfg_bundle(int mrru, int mtru, int add_fd(ppp_dev_fd); } @@ -129,14 +129,14 @@ Signed-off-by: George Kashperko +#ifdef USE_TDB + char tmp[11]; + slprintf(tmp, sizeof(tmp), "%d", ifunit); -+ script_setenv("IFUNIT", tmp, 0); ++ ppp_script_setenv("IFUNIT", tmp, 0); +#endif +} + /* * make_new_bundle - create a new PPP unit (i.e. a bundle) * and connect our channel to it. This should only get called -@@ -941,6 +951,8 @@ void make_new_bundle(int mrru, int mtru, +@@ -1002,6 +1012,8 @@ void make_new_bundle(int mrru, int mtru, /* set the mrru and flags */ cfg_bundle(mrru, mtru, rssn, tssn); diff --git a/package/network/services/ppp/patches/330-retain_foreign_default_routes.patch b/package/network/services/ppp/patches/330-retain_foreign_default_routes.patch deleted file mode 100644 index 3d2a815dbd..0000000000 --- a/package/network/services/ppp/patches/330-retain_foreign_default_routes.patch +++ /dev/null @@ -1,22 +0,0 @@ -pppd: Retain foreign default routes on Linux - -On Linux, when pppd attempts to delete its default route it does not fill -the rt_dev field of the struct rtentry used to match the system default route. -As a consequence, pppd happily deletes any default route even if it belongs -to another interface. - -This patch makes pppd fill out the rt_dev field so that only own default -routes are ever matched. - -Signed-off-by: Jo-Philipp Wich - ---- a/pppd/sys-linux.c -+++ b/pppd/sys-linux.c -@@ -2248,6 +2248,7 @@ int cifdefaultroute (int unit, u_int32_t - SIN_ADDR(rt.rt_genmask) = 0L; - } - -+ rt.rt_dev = ifname; - rt.rt_flags = RTF_UP; - if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) { - if (still_ppp()) { diff --git a/package/network/services/ppp/patches/340-populate_default_gateway.patch b/package/network/services/ppp/patches/340-populate_default_gateway.patch index 64d03fb5c4..f327971346 100644 --- a/package/network/services/ppp/patches/340-populate_default_gateway.patch +++ b/package/network/services/ppp/patches/340-populate_default_gateway.patch @@ -13,7 +13,7 @@ Signed-off-by: Jo-Philipp Wich --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c -@@ -2198,6 +2198,9 @@ int sifdefaultroute (int unit, u_int32_t +@@ -2251,6 +2251,9 @@ int sifdefaultroute (int unit, u_int32_t memset (&rt, 0, sizeof (rt)); SET_SA_FAMILY (rt.rt_dst, AF_INET); @@ -23,7 +23,7 @@ Signed-off-by: Jo-Philipp Wich rt.rt_dev = ifname; rt.rt_metric = dfl_route_metric + 1; /* +1 for binary compatibility */ -@@ -2206,7 +2209,7 @@ int sifdefaultroute (int unit, u_int32_t +@@ -2259,7 +2262,7 @@ int sifdefaultroute (int unit, u_int32_t SIN_ADDR(rt.rt_genmask) = 0L; } diff --git a/package/network/services/ppp/patches/400-simplify_kernel_checks.patch b/package/network/services/ppp/patches/400-simplify_kernel_checks.patch index 9d0ea9a0b8..137937c244 100644 --- a/package/network/services/ppp/patches/400-simplify_kernel_checks.patch +++ b/package/network/services/ppp/patches/400-simplify_kernel_checks.patch @@ -10,7 +10,7 @@ Signed-off-by: Jo-Philipp Wich --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c -@@ -235,7 +235,7 @@ static int driver_is_old = 0; +@@ -231,7 +231,7 @@ static int driver_is_old = 0; static int restore_term = 0; /* 1 => we've munged the terminal */ static struct termios inittermios; /* Initial TTY termios */ @@ -19,7 +19,7 @@ Signed-off-by: Jo-Philipp Wich static char loop_name[20]; static unsigned char inbuf[512]; /* buffer for chars read from loopback */ -@@ -254,8 +254,8 @@ static int looped; /* 1 if using loop +@@ -250,8 +250,8 @@ static int looped; /* 1 if using loop static int link_mtu; /* mtu for the link (not bundle) */ static struct utsname utsname; /* for the kernel version */ @@ -29,7 +29,7 @@ Signed-off-by: Jo-Philipp Wich #define MAX_IFS 100 -@@ -1933,11 +1933,12 @@ int ccp_fatal_error (int unit) +@@ -1970,11 +1970,12 @@ int ccp_fatal_error (int unit) * * path_to_procfs - find the path to the proc file system mount point */ @@ -44,7 +44,7 @@ Signed-off-by: Jo-Philipp Wich struct mntent *mntent; FILE *fp; -@@ -1959,6 +1960,7 @@ static char *path_to_procfs(const char * +@@ -1996,6 +1997,7 @@ static char *path_to_procfs(const char * fclose (fp); } } @@ -52,7 +52,7 @@ Signed-off-by: Jo-Philipp Wich strlcpy(proc_path + proc_path_len, tail, sizeof(proc_path) - proc_path_len); -@@ -2843,15 +2845,19 @@ int ppp_available(void) +@@ -2895,15 +2897,19 @@ int ppp_check_kernel_support(void) int my_version, my_modification, my_patch; int osmaj, osmin, ospatch; @@ -72,7 +72,7 @@ Signed-off-by: Jo-Philipp Wich /* XXX should get from driver */ driver_version = 2; -@@ -2911,6 +2917,7 @@ int ppp_available(void) +@@ -2963,6 +2969,7 @@ int ppp_check_kernel_support(void) if (ok && ((ifr.ifr_hwaddr.sa_family & ~0xFF) != ARPHRD_PPP)) ok = 0; @@ -80,7 +80,7 @@ Signed-off-by: Jo-Philipp Wich /* * This is the PPP device. Validate the version of the driver at this -@@ -3592,6 +3599,7 @@ get_pty(int *master_fdp, int *slave_fdp, +@@ -3577,6 +3584,7 @@ get_pty(int *master_fdp, int *slave_fdp, } #endif /* TIOCGPTN */ @@ -88,7 +88,7 @@ Signed-off-by: Jo-Philipp Wich if (sfd < 0) { /* the old way - scan through the pty name space */ for (i = 0; i < 64; ++i) { -@@ -3610,6 +3618,7 @@ get_pty(int *master_fdp, int *slave_fdp, +@@ -3601,6 +3609,7 @@ get_pty(int *master_fdp, int *slave_fdp, } } } @@ -98,26 +98,26 @@ Signed-off-by: Jo-Philipp Wich return 0; --- a/pppd/plugins/pppoatm/pppoatm.c +++ b/pppd/plugins/pppoatm/pppoatm.c -@@ -171,14 +171,6 @@ static void disconnect_pppoatm(void) +@@ -179,14 +179,6 @@ static void disconnect_pppoatm(void) void plugin_init(void) { -#ifdef linux - extern int new_style_driver; /* From sys-linux.c */ -- if (!ppp_available() && !new_style_driver) +- if (!ppp_check_kernel_support() && !new_style_driver) - fatal("Kernel doesn't support ppp_generic - " - "needed for PPPoATM"); -#else - fatal("No PPPoATM support on this OS"); -#endif - add_options(pppoa_options); + ppp_add_options(pppoa_options); } --- a/pppd/plugins/pppoe/plugin.c +++ b/pppd/plugins/pppoe/plugin.c -@@ -58,9 +58,6 @@ static char const RCSID[] = +@@ -57,9 +57,6 @@ static char const RCSID[] = - char pppd_version[] = VERSION; + char pppd_version[] = PPPD_VERSION; -/* From sys-linux.c in pppd -- MUST FIX THIS! */ -extern int new_style_driver; @@ -125,30 +125,30 @@ Signed-off-by: Jo-Philipp Wich char *pppd_pppoe_service = NULL; static char *acName = NULL; static char *existingSession = NULL; -@@ -407,10 +404,6 @@ PPPoEDevnameHook(char *cmd, char **argv, +@@ -421,10 +418,6 @@ PPPoEDevnameHook(char *cmd, char **argv, void plugin_init(void) { -- if (!ppp_available() && !new_style_driver) { +- if (!ppp_check_kernel_support() && !new_style_driver) { - fatal("Linux kernel does not support PPPoE -- are you running 2.4.x?"); - } - - add_options(Options); + ppp_add_options(Options); - info("PPPoE plugin from pppd %s", VERSION); + info("PPPoE plugin from pppd %s", PPPD_VERSION); --- a/pppd/plugins/pppol2tp/pppol2tp.c +++ b/pppd/plugins/pppol2tp/pppol2tp.c -@@ -490,12 +490,7 @@ static void pppol2tp_cleanup(void) +@@ -500,12 +500,7 @@ static void pppol2tp_cleanup(void) void plugin_init(void) { -#if defined(__linux__) - extern int new_style_driver; /* From sys-linux.c */ -- if (!ppp_available() && !new_style_driver) +- if (!ppp_check_kernel_support() && !new_style_driver) - fatal("Kernel doesn't support ppp_generic - " - "needed for PPPoL2TP"); -#else +#if !defined(__linux__) fatal("No PPPoL2TP support on this OS"); #endif - add_options(pppol2tp_options); + ppp_add_options(pppol2tp_options); diff --git a/package/network/services/ppp/patches/401-no_record_file.patch b/package/network/services/ppp/patches/401-no_record_file.patch index 0304f36fe2..5ef1a178d7 100644 --- a/package/network/services/ppp/patches/401-no_record_file.patch +++ b/package/network/services/ppp/patches/401-no_record_file.patch @@ -5,19 +5,19 @@ information to the permanent storage, therfore remove this option. Signed-off-by: Jo-Philipp Wich ---- a/pppd/pppd.h -+++ b/pppd/pppd.h -@@ -318,7 +318,6 @@ extern int holdoff; /* Dead time before +--- a/pppd/pppd-private.h ++++ b/pppd/pppd-private.h +@@ -187,7 +187,6 @@ extern int holdoff; /* Dead time before extern bool holdoff_specified; /* true if user gave a holdoff value */ extern bool notty; /* Stdin/out is not a tty */ extern char *pty_socket; /* Socket to connect to pty */ -extern char *record_file; /* File to record chars sent/received */ - extern bool sync_serial; /* Device is synchronous serial device */ extern int maxfail; /* Max # of unsuccessful connection attempts */ - extern char linkname[MAXPATHLEN]; /* logical name for link */ + extern char linkname[]; /* logical name for link */ + extern bool tune_kernel; /* May alter kernel settings as necessary */ --- a/pppd/tty.c +++ b/pppd/tty.c -@@ -143,7 +143,7 @@ char *disconnect_script = NULL; /* Scrip +@@ -150,7 +150,7 @@ char *disconnect_script = NULL; /* Scrip char *welcomer = NULL; /* Script to run after phys link estab. */ char *ptycommand = NULL; /* Command to run on other side of pty */ bool notty = 0; /* Stdin/out is not a tty */ @@ -26,7 +26,7 @@ Signed-off-by: Jo-Philipp Wich int max_data_rate; /* max bytes/sec through charshunt */ bool sync_serial = 0; /* Device is synchronous serial device */ char *pty_socket = NULL; /* Socket to connect to pty */ -@@ -199,8 +199,10 @@ option_t tty_options[] = { +@@ -206,8 +206,10 @@ static struct option tty_options[] = { "Send and receive over socket, arg is host:port", OPT_PRIO | OPT_DEVNAM }, diff --git a/package/network/services/ppp/patches/403-no_wtmp.patch b/package/network/services/ppp/patches/403-no_wtmp.patch deleted file mode 100644 index 90c2a8208a..0000000000 --- a/package/network/services/ppp/patches/403-no_wtmp.patch +++ /dev/null @@ -1,25 +0,0 @@ -pppd: Disable wtmp support - -Many uClibc based environments lack wtmp and utmp support, therfore remove -the code updating the wtmp information. - -Signed-off-by: Jo-Philipp Wich - ---- a/pppd/sys-linux.c -+++ b/pppd/sys-linux.c -@@ -2981,6 +2981,7 @@ int ppp_available(void) - - void logwtmp (const char *line, const char *name, const char *host) - { -+#if 0 - struct utmp ut, *utp; - pid_t mypid = getpid(); - #if __GLIBC__ < 2 -@@ -3046,6 +3047,7 @@ void logwtmp (const char *line, const ch - close (wtmp); - } - #endif -+#endif - } - #endif /* HAVE_LOGWTMP */ - diff --git a/package/network/services/ppp/patches/404-remove_obsolete_protocol_names.patch b/package/network/services/ppp/patches/404-remove_obsolete_protocol_names.patch index 8bed425a5b..6b2d15ed25 100644 --- a/package/network/services/ppp/patches/404-remove_obsolete_protocol_names.patch +++ b/package/network/services/ppp/patches/404-remove_obsolete_protocol_names.patch @@ -7,7 +7,7 @@ Signed-off-by: Jo-Philipp Wich --- a/pppd/main.c +++ b/pppd/main.c -@@ -867,14 +867,17 @@ struct protocol_list { +@@ -984,14 +984,17 @@ struct protocol_list { const char *name; } protocol_list[] = { { 0x21, "IP" }, @@ -25,7 +25,7 @@ Signed-off-by: Jo-Philipp Wich { 0x33, "Stream Protocol ST-II" }, { 0x35, "Banyan Vines" }, { 0x39, "AppleTalk EDDP" }, -@@ -888,8 +891,11 @@ struct protocol_list { +@@ -1005,8 +1008,11 @@ struct protocol_list { { 0x49, "Serial Data Transport Protocol (PPP-SDTP)" }, { 0x4b, "SNA over 802.2" }, { 0x4d, "SNA" }, @@ -37,7 +37,7 @@ Signed-off-by: Jo-Philipp Wich { 0x53, "Encryption" }, { 0x55, "Individual Link Encryption" }, { 0x57, "IPv6" }, -@@ -900,12 +906,15 @@ struct protocol_list { +@@ -1017,12 +1023,15 @@ struct protocol_list { { 0x65, "RTP IPHC Compressed non-TCP" }, { 0x67, "RTP IPHC Compressed UDP 8" }, { 0x69, "RTP IPHC Compressed RTP 8" }, @@ -53,7 +53,7 @@ Signed-off-by: Jo-Philipp Wich { 0x0203, "IBM Source Routing BPDU" }, { 0x0205, "DEC LANBridge100 Spanning Tree" }, { 0x0207, "Cisco Discovery Protocol" }, -@@ -917,15 +926,19 @@ struct protocol_list { +@@ -1034,15 +1043,19 @@ struct protocol_list { { 0x0231, "Luxcom" }, { 0x0233, "Sigma Network Systems" }, { 0x0235, "Apple Client Server Protocol" }, @@ -73,7 +73,7 @@ Signed-off-by: Jo-Philipp Wich { 0x4001, "Cray Communications Control Protocol" }, { 0x4003, "CDPD Mobile Network Registration Protocol" }, { 0x4005, "Expand accelerator protocol" }, -@@ -936,8 +949,10 @@ struct protocol_list { +@@ -1053,8 +1066,10 @@ struct protocol_list { { 0x4023, "RefTek Protocol" }, { 0x4025, "Fibre Channel" }, { 0x4027, "EMIT Protocols" }, @@ -84,7 +84,7 @@ Signed-off-by: Jo-Philipp Wich { 0x8023, "OSI Network Layer Control Protocol" }, { 0x8025, "Xerox NS IDP Control Protocol" }, { 0x8027, "DECnet Phase IV Control Protocol" }, -@@ -946,7 +961,9 @@ struct protocol_list { +@@ -1063,7 +1078,9 @@ struct protocol_list { { 0x8031, "Bridging NCP" }, { 0x8033, "Stream Protocol Control Protocol" }, { 0x8035, "Banyan Vines Control Protocol" }, @@ -94,7 +94,7 @@ Signed-off-by: Jo-Philipp Wich { 0x803f, "NETBIOS Framing Control Protocol" }, { 0x8041, "Cisco Systems Control Protocol" }, { 0x8043, "Ascom Timeplex" }, -@@ -955,18 +972,24 @@ struct protocol_list { +@@ -1072,18 +1089,24 @@ struct protocol_list { { 0x8049, "Serial Data Control Protocol (PPP-SDCP)" }, { 0x804b, "SNA over 802.2 Control Protocol" }, { 0x804d, "SNA Control Protocol" }, @@ -119,7 +119,7 @@ Signed-off-by: Jo-Philipp Wich { 0x8207, "Cisco Discovery Protocol Control" }, { 0x8209, "Netcs Twin Routing" }, { 0x820b, "STP - Control Protocol" }, -@@ -975,24 +998,29 @@ struct protocol_list { +@@ -1092,24 +1115,29 @@ struct protocol_list { { 0x8281, "MPLSCP" }, { 0x8285, "IEEE p1284.4 standard - Protocol Control" }, { 0x8287, "ETSI TETRA TNP1 Control Protocol" }, diff --git a/package/network/services/ppp/patches/405-no_multilink_option.patch b/package/network/services/ppp/patches/405-no_multilink_option.patch index a34ec57b0a..654bebd569 100644 --- a/package/network/services/ppp/patches/405-no_multilink_option.patch +++ b/package/network/services/ppp/patches/405-no_multilink_option.patch @@ -9,7 +9,7 @@ Signed-off-by: Jo-Philipp Wich --- a/pppd/options.c +++ b/pppd/options.c -@@ -348,13 +348,14 @@ option_t general_options[] = { +@@ -379,13 +379,14 @@ struct option general_options[] = { "Enable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 1 }, { "nomultilink", o_bool, &multilink, "Disable multilink operation", OPT_PRIOSUB | 0 }, @@ -18,11 +18,11 @@ Signed-off-by: Jo-Philipp Wich { "bundle", o_string, &bundle_name, "Bundle name for multilink", OPT_PRIO }, - #endif /* HAVE_MULTILINK */ + #endif /* PPP_WITH_MULTILINK */ + { "nomp", o_bool, &multilink, + "Disable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 0 }, + - #ifdef PLUGIN + #ifdef PPP_WITH_PLUGINS { "plugin", o_special, (void *)loadplugin, "Load a plug-in module into pppd", OPT_PRIV | OPT_A2LIST }, diff --git a/package/network/services/ppp/patches/500-add-pptp-plugin.patch b/package/network/services/ppp/patches/500-add-pptp-plugin.patch index 96f4bcaf70..4b66cd2165 100644 --- a/package/network/services/ppp/patches/500-add-pptp-plugin.patch +++ b/package/network/services/ppp/patches/500-add-pptp-plugin.patch @@ -1,59 +1,43 @@ ---- a/configure -+++ b/configure -@@ -133,7 +133,7 @@ if [ -d "$ksrc" ]; then - mkmkf $ksrc/Makedefs$compiletype Makedefs.com - for dir in pppd pppstats chat pppdump pppd/plugins pppd/plugins/pppoe \ - pppd/plugins/radius pppd/plugins/pppoatm \ -- pppd/plugins/pppol2tp; do -+ pppd/plugins/pppol2tp pppd/plugins/pptp ; do - mkmkf $dir/Makefile.$makext $dir/Makefile - done - if [ -f $ksrc/Makefile.$makext$archvariant ]; then ---- a/pppd/plugins/Makefile.linux -+++ b/pppd/plugins/Makefile.linux -@@ -14,7 +14,7 @@ INSTALL = install - # EAP-TLS - CFLAGS += -DUSE_EAPTLS=1 +--- a/configure.ac ++++ b/configure.ac +@@ -344,6 +344,7 @@ AC_CONFIG_FILES([ + pppd/plugins/pppoatm/Makefile + pppd/plugins/pppol2tp/Makefile + pppd/plugins/radius/Makefile ++ pppd/plugins/pptp/Makefile + pppdump/Makefile + pppstats/Makefile + scripts/Makefile +--- a/pppd/plugins/Makefile.am ++++ b/pppd/plugins/Makefile.am +@@ -21,5 +21,5 @@ winbind_la_LDFLAGS = $(PLUGIN_LDFLAGS) + winbind_la_SOURCES = winbind.c --SUBDIRS := pppoe pppoatm pppol2tp -+SUBDIRS := pppoe pppoatm pppol2tp pptp - # Uncomment the next line to include the radius authentication plugin - SUBDIRS += radius - PLUGINS := minconn.so passprompt.so passwordfd.so winbind.so + if !SUNOS +-SUBDIRS = pppoe pppoatm pppol2tp radius ++SUBDIRS = pppoe pppoatm pppol2tp radius pptp + endif --- /dev/null -+++ b/pppd/plugins/pptp/Makefile.linux -@@ -0,0 +1,31 @@ -+# -+# This program may be distributed according to the terms of the GNU -+# General Public License, version 2 or (at your option) any later version. -+# -+# $Id: Makefile.linux,v 1.9 2012/05/04 21:48:00 dgolle Exp $ -+#*********************************************************************** ++++ b/pppd/plugins/pptp/Makefile.am +@@ -0,0 +1,18 @@ ++pppd_plugin_LTLIBRARIES = pptp.la ++pppd_plugindir = $(PPPD_PLUGIN_DIR) + -+DESTDIR = $(INSTROOT)@DESTDIR@ -+LIBDIR = $(DESTDIR)/lib/pppd/$(PPPDVERSION) -+ -+PPPDVERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h) -+ -+INSTALL = install -+ -+COPTS=-O2 -g -+CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC -DPPPD_VERSION=\"$(PPPDVERSION)\" -+all: pptp.so -+ -+%.o: %.c -+ $(CC) $(CFLAGS) -c -o $@ $< -+ -+pptp.so: dirutil.o orckit_quirks.o pptp.o pptp_callmgr.o pptp_ctrl.o pptp_quirks.o util.o vector.o -+ $(CC) -o pptp.so -shared dirutil.o orckit_quirks.o pptp.o pptp_callmgr.o pptp_ctrl.o pptp_quirks.o util.o vector.o -+ -+install: all -+ $(INSTALL) -d -m 755 $(LIBDIR) -+ $(INSTALL) -c -m 4550 pptp.so $(LIBDIR) -+ -+clean: -+ rm -f *.o *.so ++noinst_HEADERS = \ ++ dirutil.h \ ++ orckit_quirks.h \ ++ pptp_callmgr.h \ ++ pptp_ctrl.h \ ++ pptp_msg.h \ ++ pptp_options.h \ ++ pptp_quirks.h \ ++ util.h \ ++ vector.h + ++pptp_la_CPPFLAGS = -I${top_srcdir} -DSYSCONFDIR=\"${sysconfdir}\" -DPLUGIN ++pptp_la_LDFLAGS = -fPIC -module -avoid-version ++pptp_la_SOURCES = dirutil.c orckit_quirks.c pptp.c pptp_callmgr.c pptp_ctrl.c \ ++ pptp_quirks.c util.c vector.c --- /dev/null +++ b/pppd/plugins/pptp/dirutil.c @@ -0,0 +1,68 @@ @@ -334,7 +318,7 @@ +xeb xeb@mail.ru --- /dev/null +++ b/pppd/plugins/pptp/pptp.c -@@ -0,0 +1,323 @@ +@@ -0,0 +1,325 @@ +/*************************************************************************** + * Copyright (C) 2006 by Kozlov D. * + * some cleanup done (C) 2012 by Daniel Golle * @@ -377,6 +361,8 @@ +#include + +#include "pppd.h" ++#include "pppd-private.h" ++#include "options.h" +#include "fsm.h" +#include "lcp.h" +#include "ipcp.h" @@ -385,7 +371,7 @@ + +#include "pptp_callmgr.h" +#include -+#include ++#include +#include + +#include @@ -437,8 +423,8 @@ + check_options: NULL, + connect: &pptp_connect, + disconnect: &pptp_disconnect, -+ establish_ppp: &generic_establish_ppp, -+ disestablish_ppp: &generic_disestablish_ppp, ++ establish_ppp: &ppp_generic_establish, ++ disestablish_ppp: &ppp_generic_disestablish, + close: NULL, + cleanup: NULL +}; @@ -446,7 +432,7 @@ +static int pptp_start_server(void) +{ + pptp_fd=pptp_sock; -+ sprintf(ppp_devnam,"pptp (%s)",pptp_client); ++ sprintf(ppp_devname,"pptp (%s)",pptp_client); + + return pptp_fd; +} @@ -527,7 +513,7 @@ + return -1; + } + -+ sprintf(ppp_devnam,"pptp (%s)",pptp_server); ++ sprintf(ppp_devname,"pptp (%s)",pptp_server); + + return pptp_fd; +} @@ -651,7 +637,7 @@ + +void plugin_init(void) +{ -+ add_options(Options); ++ ppp_add_options(Options); + + info("PPTP plugin version %s", PPTP_VERSION); + diff --git a/package/network/services/ppp/patches/510-pptp_compile_fix.patch b/package/network/services/ppp/patches/510-pptp_compile_fix.patch deleted file mode 100644 index 04bb620e76..0000000000 --- a/package/network/services/ppp/patches/510-pptp_compile_fix.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/pppd/plugins/pptp/pptp.c -+++ b/pppd/plugins/pptp/pptp.c -@@ -48,7 +48,7 @@ - - #include "pptp_callmgr.h" - #include --#include -+#include - #include - - #include diff --git a/package/network/services/ppp/patches/511-pptp_cflags.patch b/package/network/services/ppp/patches/511-pptp_cflags.patch deleted file mode 100644 index 548bf41c1f..0000000000 --- a/package/network/services/ppp/patches/511-pptp_cflags.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/pppd/plugins/pptp/Makefile.linux -+++ b/pppd/plugins/pptp/Makefile.linux -@@ -20,7 +20,7 @@ all: pptp.so - $(CC) $(CFLAGS) -c -o $@ $< - - pptp.so: dirutil.o orckit_quirks.o pptp.o pptp_callmgr.o pptp_ctrl.o pptp_quirks.o util.o vector.o -- $(CC) -o pptp.so -shared dirutil.o orckit_quirks.o pptp.o pptp_callmgr.o pptp_ctrl.o pptp_quirks.o util.o vector.o -+ $(CC) -fPIC -o pptp.so -shared dirutil.o orckit_quirks.o pptp.o pptp_callmgr.o pptp_ctrl.o pptp_quirks.o util.o vector.o - - install: all - $(INSTALL) -d -m 755 $(LIBDIR) diff --git a/package/network/services/ppp/patches/512-syncppp.patch b/package/network/services/ppp/patches/512-syncppp.patch index 6f404071b8..fcc8c34c92 100644 --- a/package/network/services/ppp/patches/512-syncppp.patch +++ b/package/network/services/ppp/patches/512-syncppp.patch @@ -1,16 +1,16 @@ ---- a/pppd/chap-new.c -+++ b/pppd/chap-new.c -@@ -37,6 +37,9 @@ - #include "chap-new.h" +--- a/pppd/chap.c ++++ b/pppd/chap.c +@@ -42,6 +42,9 @@ + #include "chap.h" #include "chap-md5.h" +#include +#include "syncppp.h" + - #ifdef CHAPMS + #ifdef PPP_WITH_CHAPMS #include "chap_ms.h" #define MDTYPE_ALL (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5) -@@ -523,6 +526,18 @@ chap_respond(struct chap_client_state *c +@@ -520,6 +523,18 @@ chap_respond(struct chap_client_state *c p[2] = len >> 8; p[3] = len; @@ -29,40 +29,36 @@ output(0, response, PPP_HDRLEN + len); } ---- a/pppd/Makefile.linux -+++ b/pppd/Makefile.linux -@@ -17,16 +17,16 @@ TARGETS = pppd +--- a/pppd/Makefile.am ++++ b/pppd/Makefile.am +@@ -67,6 +67,7 @@ noinst_HEADERS = \ + peap.h \ + pppd-private.h \ + spinlock.h \ ++ syncppp.h \ + tls.h \ + tdb.h - PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap-new.c md5.c ccp.c \ - ecp.c ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c \ -- demand.c utils.c tty.c eap.c chap-md5.c session.c -+ demand.c utils.c tty.c eap.c chap-md5.c session.c syncppp.c +@@ -85,6 +86,7 @@ pppd_SOURCES = \ + main.c \ + options.c \ + session.c \ ++ syncppp.c \ + tty.c \ + upap.c \ + utils.c +@@ -95,7 +97,7 @@ BUILT_SOURCE = \ - HEADERS = ccp.h session.h chap-new.h ecp.h fsm.h ipcp.h \ - ipxcp.h lcp.h magic.h md5.h patchlevel.h pathnames.h pppd.h \ -- upap.h eap.h -+ upap.h eap.h syncppp.h + pppd_CPPFLAGS = -DSYSCONFDIR=\"${sysconfdir}\" -DPPPD_RUNTIME_DIR='"@PPPD_RUNTIME_DIR@"' -DPPPD_LOGFILE_DIR='"@PPPD_LOGFILE_DIR@"' + pppd_LDFLAGS = +-pppd_LIBS = ++pppd_LIBS = -lpthread - MANPAGES = pppd.8 - PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o md5.o ccp.o \ - ecp.o auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o \ -- eap.o chap-md5.o session.o -+ eap.o chap-md5.o session.o syncppp.o - - # - # include dependencies if present -@@ -34,7 +34,7 @@ ifeq (.depend,$(wildcard .depend)) - include .depend - endif - --LIBS = -lrt -+LIBS = -lpthread - - # Uncomment the next line to include support for Microsoft's - # MS-CHAP authentication protocol. Also, edit plugins/radius/Makefile.linux. + if PPP_WITH_SYSTEM_CA_PATH + pppd_CPPFLAGS += -DSYSTEM_CA_PATH='"@SYSTEM_CA_PATH@"' --- a/pppd/options.c +++ b/pppd/options.c -@@ -127,6 +127,7 @@ bool dump_options; /* print out option +@@ -136,6 +136,7 @@ bool show_options; /* print all support bool dryrun; /* print out option values and exit */ char *domain; /* domain name set by domain option */ int child_wait = 5; /* # seconds to wait for children at exit */ @@ -70,7 +66,7 @@ struct userenv *userenv_list; /* user environment variables */ int dfl_route_metric = -1; /* metric of the default route to set over the PPP link */ -@@ -323,6 +324,9 @@ option_t general_options[] = { +@@ -339,6 +340,9 @@ struct option general_options[] = { "Unset user environment variable", OPT_A2PRINTER | OPT_NOPRINT, (void *)user_unsetprint }, @@ -80,16 +76,16 @@ { "defaultroute-metric", o_int, &dfl_route_metric, "Metric to use for the default route (Linux only; -1 for default behavior)", OPT_PRIV|OPT_LLIMIT|OPT_INITONLY, NULL, 0, -1 }, ---- a/pppd/pppd.h -+++ b/pppd/pppd.h -@@ -336,6 +336,7 @@ extern char *bundle_name; /* bundle name - extern bool dump_options; /* print out option values */ +--- a/pppd/pppd-private.h ++++ b/pppd/pppd-private.h +@@ -207,6 +207,7 @@ extern bool dump_options; /* print out o + extern bool show_options; /* show all option names and descriptions */ extern bool dryrun; /* check everything, print options, exit */ extern int child_wait; /* # seconds to wait for children at end */ +extern int npppd; /* synchronize between multiple pppd */ - - #ifdef USE_EAPTLS - extern char *crl_dir; + extern char *current_option; /* the name of the option being parsed */ + extern int privileged_option; /* set iff the current option came from root */ + extern char *option_source; /* string saying where the option came from */ --- /dev/null +++ b/pppd/syncppp.c @@ -0,0 +1,75 @@ @@ -177,8 +173,8 @@ +extern int syncppp(int nproc); --- a/pppd/upap.c +++ b/pppd/upap.c -@@ -50,6 +50,8 @@ - #include "pppd.h" +@@ -55,6 +55,8 @@ + #include "options.h" #include "upap.h" +#include @@ -186,7 +182,7 @@ static bool hide_password = 1; -@@ -540,6 +542,18 @@ upap_sauthreq(upap_state *u) +@@ -545,6 +547,18 @@ upap_sauthreq(upap_state *u) PUTCHAR(u->us_passwdlen, outp); BCOPY(u->us_passwd, outp, u->us_passwdlen); diff --git a/package/network/services/ppp/patches/600-Revert-pppd-Use-openssl-for-the-DES-instead-of-the-l.patch b/package/network/services/ppp/patches/600-Revert-pppd-Use-openssl-for-the-DES-instead-of-the-l.patch deleted file mode 100644 index a3042af533..0000000000 --- a/package/network/services/ppp/patches/600-Revert-pppd-Use-openssl-for-the-DES-instead-of-the-l.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 831dca008699d485f2c8e91749657ef2d0b06166 Mon Sep 17 00:00:00 2001 -From: Martin Schiller -Date: Thu, 6 Dec 2018 08:43:17 +0100 -Subject: [PATCH] Revert "pppd: Use openssl for the DES instead of the libcrypt - / glibc" - -For musl and glibc2.27 we can keep linking to crypt; however if we -switch to glibc 2.28 we will have to link to one of the SSL libraries. - -This reverts commit 3c7b86229f7bd2600d74db14b1fe5b3896be3875. ---- - pppd/Makefile.linux | 7 +++---- - pppd/pppcrypt.c | 18 +++++++++--------- - 2 files changed, 12 insertions(+), 13 deletions(-) - ---- a/pppd/Makefile.linux -+++ b/pppd/Makefile.linux -@@ -36,10 +36,10 @@ endif - - LIBS = -lpthread - --# Uncomment the next line to include support for Microsoft's -+# Uncomment the next 2 lines to include support for Microsoft's - # MS-CHAP authentication protocol. Also, edit plugins/radius/Makefile.linux. - CHAPMS=y --#USE_CRYPT=y -+USE_CRYPT=y - # Don't use MSLANMAN unless you really know what you're doing. - #MSLANMAN=y - # Uncomment the next line to include support for MPPE. CHAPMS (above) must -@@ -158,8 +158,7 @@ endif - - ifdef NEEDDES - ifndef USE_CRYPT --CFLAGS += -I$(shell $(CC) --print-sysroot)/usr/include/openssl --NEEDCRYPTOLIB = y -+LIBS += -ldes $(LIBS) - else - CFLAGS += -DUSE_CRYPT=1 - endif ---- a/pppd/pppcrypt.c -+++ b/pppd/pppcrypt.c -@@ -62,7 +62,7 @@ MakeKey(u_char *key, u_char *des_key) - des_key[7] = Get7Bits(key, 49); - - #ifndef USE_CRYPT -- DES_set_odd_parity((DES_cblock *)des_key); -+ des_set_odd_parity((des_cblock *)des_key); - #endif - } - -@@ -147,30 +147,30 @@ DesDecrypt(u_char *cipher, u_char *clear - } - - #else /* USE_CRYPT */ --static DES_key_schedule key_schedule; -+static des_key_schedule key_schedule; - - bool - DesSetkey(u_char *key) - { -- DES_cblock des_key; -+ des_cblock des_key; - MakeKey(key, des_key); -- DES_set_key(&des_key, &key_schedule); -+ des_set_key(&des_key, key_schedule); - return (1); - } - - bool - DesEncrypt(u_char *clear, u_char *cipher) - { -- DES_ecb_encrypt((DES_cblock *)clear, (DES_cblock *)cipher, -- &key_schedule, 1); -+ des_ecb_encrypt((des_cblock *)clear, (des_cblock *)cipher, -+ key_schedule, 1); - return (1); - } - - bool - DesDecrypt(u_char *cipher, u_char *clear) - { -- DES_ecb_encrypt((DES_cblock *)cipher, (DES_cblock *)clear, -- &key_schedule, 0); -+ des_ecb_encrypt((des_cblock *)cipher, (des_cblock *)clear, -+ key_schedule, 0); - return (1); - } - diff --git a/package/network/services/ppp/patches/610-pppd_compile_fix.patch b/package/network/services/ppp/patches/610-pppd_compile_fix.patch deleted file mode 100644 index 4f66e5d71f..0000000000 --- a/package/network/services/ppp/patches/610-pppd_compile_fix.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/pppd/Makefile.linux -+++ b/pppd/Makefile.linux -@@ -49,7 +49,8 @@ MPPE=y - # Uncomment the next line to include support for PPP packet filtering. - # This requires that the libpcap library and headers be installed - # and that the kernel driver support PPP packet filtering. --#FILTER=y -+# libpcap statically linked in OpenWRT, hence disabled here. -+FILTER= - - # Support for precompiled filters - PRECOMPILED_FILTER=y diff --git a/scripts/download.pl b/scripts/download.pl index 1d62fce7c2..2b82b4a065 100755 --- a/scripts/download.pl +++ b/scripts/download.pl @@ -11,6 +11,7 @@ use strict; use warnings; use File::Basename; use File::Copy; +use File::Path; use Text::ParseWords; use JSON::PP; @@ -173,7 +174,7 @@ sub download } if (! -d "$target") { - system("mkdir", "-p", "$target/"); + make_path($target); } if (! open TMPDLS, "find $mirror -follow -name $filename 2>/dev/null |") { @@ -244,7 +245,7 @@ sub download }; unlink "$target/$filename"; - system("mv", "$target/$filename.dl", "$target/$filename"); + move("$target/$filename.dl", "$target/$filename"); cleanup(); } diff --git a/target/linux/generic/backport-6.6/901-v6.13-net-dsa-mv88e6xxx-Support-LED-control.patch b/target/linux/generic/backport-6.6/901-v6.13-net-dsa-mv88e6xxx-Support-LED-control.patch new file mode 100644 index 0000000000..8557fe2510 --- /dev/null +++ b/target/linux/generic/backport-6.6/901-v6.13-net-dsa-mv88e6xxx-Support-LED-control.patch @@ -0,0 +1,1250 @@ +From 7b590490e3aa6bfa38bf6e2069a529017fd3c1d2 Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Fri, 13 Oct 2023 00:08:35 +0200 +Subject: [PATCH] net: dsa: mv88e6xxx: Support LED control + +This adds control over the hardware LEDs in the Marvell +MV88E6xxx DSA switch and enables it for MV88E6352. + +This fixes an imminent problem on the Inteno XG6846 which +has a WAN LED that simply do not work with hardware +defaults: driver amendment is necessary. + +The patch is modeled after Christian Marangis LED support +code for the QCA8k DSA switch, I got help with the register +definitions from Tim Harvey. + +After this patch it is possible to activate hardware link +indication like this (or with a similar script): + + cd /sys/class/leds/Marvell\ 88E6352:05:00:green:wan/ + echo netdev > trigger + echo 1 > link + +This makes the green link indicator come up on any link +speed. It is also possible to be more elaborate, like this: + + cd /sys/class/leds/Marvell\ 88E6352:05:00:green:wan/ + echo netdev > trigger + echo 1 > link_1000 + cd /sys/class/leds/Marvell\ 88E6352:05:01:amber:wan/ + echo netdev > trigger + echo 1 > link_100 + +Making the green LED come on for a gigabit link and the +amber LED come on for a 100 mbit link. + +Each port has 2 LED slots (the hardware may use just one or +none) and the hardware triggers are specified in four bits per +LED, and some of the hardware triggers are only available on the +SFP (fiber) uplink. The restrictions are described in the +port.h header file where the registers are described. For +example, selector 1 set for LED 1 on port 5 or 6 will indicate +Fiber 1000 (gigabit) and activity with a blinking LED, but +ONLY for an SFP connection. If port 5/6 is used with something +not SFP, this selector is a noop: something else need to be +selected. + +After the previous series rewriting the MV88E6xxx DT +bindings to use YAML a "leds" subnode is already valid +for each port, in my scratch device tree it looks like +this: + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "off"; + linux,default-trigger = "netdev"; + }; + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "off"; + }; + }; + +This DT config is not yet configuring everything: when the netdev +default trigger is assigned the hw acceleration callbacks are +not called, and there is no way to set the netdev sub-trigger +type (such as link_1000) from the device tree, such as if you want +a gigabit link indicator. This has to be done from userspace at +this point. + +We add LED operations to all switches in the 6352 family: +6172, 6176, 6240 and 6352. + +Signed-off-by: Linus Walleij +--- + drivers/net/dsa/mv88e6xxx/Kconfig | 10 + + drivers/net/dsa/mv88e6xxx/Makefile | 1 + + drivers/net/dsa/mv88e6xxx/chip.c | 38 +- + drivers/net/dsa/mv88e6xxx/chip.h | 11 + + drivers/net/dsa/mv88e6xxx/leds.c | 839 +++++++++++++++++++++++++++++ + drivers/net/dsa/mv88e6xxx/port.c | 1 + + drivers/net/dsa/mv88e6xxx/port.h | 133 +++++ + 7 files changed, 1031 insertions(+), 2 deletions(-) + create mode 100644 drivers/net/dsa/mv88e6xxx/leds.c + +--- a/drivers/net/dsa/mv88e6xxx/Kconfig ++++ b/drivers/net/dsa/mv88e6xxx/Kconfig +@@ -17,3 +17,13 @@ config NET_DSA_MV88E6XXX_PTP + help + Say Y to enable PTP hardware timestamping on Marvell 88E6xxx switch + chips that support it. ++ ++config NET_DSA_MV88E6XXX_LEDS ++ bool "LED support for Marvell 88E6xxx" ++ default y ++ depends on NET_DSA_MV88E6XXX ++ depends on LEDS_CLASS=y || LEDS_CLASS=NET_DSA_MV88E6XXX ++ depends on LEDS_TRIGGERS ++ help ++ This enabled support for controlling the LEDs attached to the ++ Marvell 88E6xxx switch chips. +--- a/drivers/net/dsa/mv88e6xxx/Makefile ++++ b/drivers/net/dsa/mv88e6xxx/Makefile +@@ -9,6 +9,7 @@ mv88e6xxx-objs += global2.o + mv88e6xxx-objs += global2_avb.o + mv88e6xxx-objs += global2_scratch.o + mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += hwtstamp.o ++mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_LEDS) += leds.o + mv88e6xxx-objs += pcs-6185.o + mv88e6xxx-objs += pcs-6352.o + mv88e6xxx-objs += pcs-639x.o +--- a/drivers/net/dsa/mv88e6xxx/chip.c ++++ b/drivers/net/dsa/mv88e6xxx/chip.c +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -3235,14 +3236,43 @@ static int mv88e6xxx_setup_upstream_port + static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) + { + struct device_node *phy_handle = NULL; ++ struct fwnode_handle *ports_fwnode; ++ struct fwnode_handle *port_fwnode; + struct dsa_switch *ds = chip->ds; ++ struct mv88e6xxx_port *p; + struct dsa_port *dp; + int tx_amp; + int err; + u16 reg; ++ u32 val; + +- chip->ports[port].chip = chip; +- chip->ports[port].port = port; ++ p = &chip->ports[port]; ++ p->chip = chip; ++ p->port = port; ++ ++ /* Look up corresponding fwnode if any */ ++ ports_fwnode = device_get_named_child_node(chip->dev, "ethernet-ports"); ++ if (!ports_fwnode) ++ ports_fwnode = device_get_named_child_node(chip->dev, "ports"); ++ if (ports_fwnode) { ++ fwnode_for_each_child_node(ports_fwnode, port_fwnode) { ++ if (fwnode_property_read_u32(port_fwnode, "reg", &val)) ++ continue; ++ if (val == port) { ++ p->fwnode = port_fwnode; ++ p->fiber = fwnode_property_present(port_fwnode, "sfp"); ++ break; ++ } ++ } ++ } else { ++ dev_dbg(chip->dev, "no ethernet ports node defined for the device\n"); ++ } ++ ++ if (chip->info->ops->port_setup_leds) { ++ err = chip->info->ops->port_setup_leds(chip, port); ++ if (err && err != -EOPNOTSUPP) ++ return err; ++ } + + err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, + SPEED_UNFORCED, DUPLEX_UNFORCED, +@@ -4461,6 +4491,7 @@ static const struct mv88e6xxx_ops mv88e6 + .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, + .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, + .port_get_cmode = mv88e6352_port_get_cmode, ++ .port_setup_leds = mv88e6xxx_port_setup_leds, + .port_setup_message_port = mv88e6xxx_setup_message_port, + .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_set_histogram = mv88e6095_g1_stats_set_histogram, +@@ -4563,6 +4594,7 @@ static const struct mv88e6xxx_ops mv88e6 + .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, + .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, + .port_get_cmode = mv88e6352_port_get_cmode, ++ .port_setup_leds = mv88e6xxx_port_setup_leds, + .port_setup_message_port = mv88e6xxx_setup_message_port, + .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_set_histogram = mv88e6095_g1_stats_set_histogram, +@@ -4838,6 +4870,7 @@ static const struct mv88e6xxx_ops mv88e6 + .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, + .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, + .port_get_cmode = mv88e6352_port_get_cmode, ++ .port_setup_leds = mv88e6xxx_port_setup_leds, + .port_setup_message_port = mv88e6xxx_setup_message_port, + .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_set_histogram = mv88e6095_g1_stats_set_histogram, +@@ -5260,6 +5293,7 @@ static const struct mv88e6xxx_ops mv88e6 + .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, + .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, + .port_get_cmode = mv88e6352_port_get_cmode, ++ .port_setup_leds = mv88e6xxx_port_setup_leds, + .port_setup_message_port = mv88e6xxx_setup_message_port, + .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_set_histogram = mv88e6095_g1_stats_set_histogram, +--- a/drivers/net/dsa/mv88e6xxx/chip.h ++++ b/drivers/net/dsa/mv88e6xxx/chip.h +@@ -13,7 +13,9 @@ + #include + #include + #include ++#include + #include ++#include + #include + #include + #include +@@ -275,6 +277,7 @@ struct mv88e6xxx_vlan { + struct mv88e6xxx_port { + struct mv88e6xxx_chip *chip; + int port; ++ struct fwnode_handle *fwnode; + struct mv88e6xxx_vlan bridge_pvid; + u64 serdes_stats[2]; + u64 atu_member_violation; +@@ -289,6 +292,11 @@ struct mv88e6xxx_port { + struct devlink_region *region; + void *pcs_private; + ++ /* LED related information */ ++ bool fiber; ++ struct led_classdev led0; ++ struct led_classdev led1; ++ + /* MacAuth Bypass control flag */ + bool mab; + }; +@@ -561,6 +569,9 @@ struct mv88e6xxx_ops { + phy_interface_t mode); + int (*port_get_cmode)(struct mv88e6xxx_chip *chip, int port, u8 *cmode); + ++ /* LED control */ ++ int (*port_setup_leds)(struct mv88e6xxx_chip *chip, int port); ++ + /* Some devices have a per port register indicating what is + * the upstream port this port should forward to. + */ +--- /dev/null ++++ b/drivers/net/dsa/mv88e6xxx/leds.c +@@ -0,0 +1,839 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++#include ++#include ++#include ++ ++#include "chip.h" ++#include "global2.h" ++#include "port.h" ++ ++/* Offset 0x16: LED control */ ++ ++static int mv88e6xxx_port_led_write(struct mv88e6xxx_chip *chip, int port, u16 reg) ++{ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_UPDATE; ++ ++ return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_LED_CONTROL, reg); ++} ++ ++static int mv88e6xxx_port_led_read(struct mv88e6xxx_chip *chip, int port, ++ u16 ptr, u16 *val) ++{ ++ int err; ++ ++ err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_LED_CONTROL, ptr); ++ if (err) ++ return err; ++ ++ err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_LED_CONTROL, val); ++ *val &= 0x3ff; ++ ++ return err; ++} ++ ++static int mv88e6xxx_led_brightness_set(struct mv88e6xxx_port *p, int led, ++ int brightness) ++{ ++ u16 reg; ++ int err; ++ ++ err = mv88e6xxx_port_led_read(p->chip, p->port, ++ MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL, ++ ®); ++ if (err) ++ return err; ++ ++ if (led == 1) ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK; ++ else ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK; ++ ++ if (brightness) { ++ /* Selector 0x0f == Force LED ON */ ++ if (led == 1) ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED1_SELF; ++ else ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED0_SELF; ++ } else { ++ /* Selector 0x0e == Force LED OFF */ ++ if (led == 1) ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED1_SELE; ++ else ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED0_SELE; ++ } ++ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL; ++ ++ return mv88e6xxx_port_led_write(p->chip, p->port, reg); ++} ++ ++static int mv88e6xxx_led0_brightness_set_blocking(struct led_classdev *ldev, ++ enum led_brightness brightness) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_brightness_set(p, 0, brightness); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++static int mv88e6xxx_led1_brightness_set_blocking(struct led_classdev *ldev, ++ enum led_brightness brightness) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_brightness_set(p, 1, brightness); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++struct mv88e6xxx_led_hwconfig { ++ int led; ++ u8 portmask; ++ unsigned long rules; ++ bool fiber; ++ bool blink_activity; ++ u16 selector; ++}; ++ ++/* The following is a lookup table to check what rules we can support on a ++ * certain LED given restrictions such as that some rules only work with fiber ++ * (SFP) connections and some blink on activity by default. ++ */ ++#define MV88E6XXX_PORTS_0_3 (BIT(0) | BIT(1) | BIT(2) | BIT(3)) ++#define MV88E6XXX_PORTS_4_5 (BIT(4) | BIT(5)) ++#define MV88E6XXX_PORT_4 BIT(4) ++#define MV88E6XXX_PORT_5 BIT(5) ++ ++/* Entries are listed in selector order. ++ * ++ * These configurations vary across different switch families, list ++ * different tables per-family here. ++ */ ++static const struct mv88e6xxx_led_hwconfig mv88e6352_led_hwconfigs[] = { ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORT_4, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL0, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORT_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL0, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL1, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_100), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL1, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_4_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100), ++ .blink_activity = true, ++ .fiber = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL1, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_4_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .fiber = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL1, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL2, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_100), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL2, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_4_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .fiber = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL2, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_4_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100), ++ .blink_activity = true, ++ .fiber = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL2, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL3, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_1000), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL3, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_4_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .fiber = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL3, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORT_4, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL4, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORT_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL5, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_FULL_DUPLEX), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL6, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL6, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORT_4, ++ .rules = BIT(TRIGGER_NETDEV_FULL_DUPLEX), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL6, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORT_5, ++ .rules = BIT(TRIGGER_NETDEV_FULL_DUPLEX), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL6, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL7, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL7, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL8, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL8, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORT_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL8, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL9, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL9, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SELA, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SELA, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SELB, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SELB, ++ }, ++}; ++ ++/* mv88e6xxx_led_match_selector() - look up the appropriate LED mode selector ++ * @p: port state container ++ * @led: LED number, 0 or 1 ++ * @blink_activity: blink the LED (usually blink on indicated activity) ++ * @fiber: the link is connected to fiber such as SFP ++ * @rules: LED status flags from the LED classdev core ++ * @selector: fill in the selector in this parameter with an OR operation ++ */ ++static int mv88e6xxx_led_match_selector(struct mv88e6xxx_port *p, int led, bool blink_activity, ++ bool fiber, unsigned long rules, u16 *selector) ++{ ++ const struct mv88e6xxx_led_hwconfig *conf; ++ int i; ++ ++ /* No rules means we turn the LED off */ ++ if (!rules) { ++ if (led == 1) ++ *selector |= MV88E6XXX_PORT_LED_CONTROL_LED1_SELE; ++ else ++ *selector |= MV88E6XXX_PORT_LED_CONTROL_LED0_SELE; ++ return 0; ++ } ++ ++ /* TODO: these rules are for MV88E6352, when adding other families, ++ * think about making sure you select the table that match the ++ * specific switch family. ++ */ ++ for (i = 0; i < ARRAY_SIZE(mv88e6352_led_hwconfigs); i++) { ++ conf = &mv88e6352_led_hwconfigs[i]; ++ ++ if (conf->led != led) ++ continue; ++ ++ if (!(conf->portmask & BIT(p->port))) ++ continue; ++ ++ if (conf->blink_activity != blink_activity) ++ continue; ++ ++ if (conf->fiber != fiber) ++ continue; ++ ++ if (conf->rules == rules) { ++ dev_dbg(p->chip->dev, "port%d LED %d set selector %04x for rules %08lx\n", ++ p->port, led, conf->selector, rules); ++ *selector |= conf->selector; ++ return 0; ++ } ++ } ++ ++ return -EOPNOTSUPP; ++} ++ ++/* mv88e6xxx_led_match_selector() - find Linux netdev rules from a selector value ++ * @p: port state container ++ * @selector: the selector value from the LED actity register ++ * @led: LED number, 0 or 1 ++ * @rules: Linux netdev activity rules found from selector ++ */ ++static int ++mv88e6xxx_led_match_rule(struct mv88e6xxx_port *p, u16 selector, int led, unsigned long *rules) ++{ ++ const struct mv88e6xxx_led_hwconfig *conf; ++ int i; ++ ++ /* Find the selector in the table, we just look for the right selector ++ * and ignore if the activity has special properties such as blinking ++ * or is fiber-only. ++ */ ++ for (i = 0; i < ARRAY_SIZE(mv88e6352_led_hwconfigs); i++) { ++ conf = &mv88e6352_led_hwconfigs[i]; ++ ++ if (conf->led != led) ++ continue; ++ ++ if (!(conf->portmask & BIT(p->port))) ++ continue; ++ ++ if (conf->selector == selector) { ++ dev_dbg(p->chip->dev, "port%d LED %d has selector %04x, rules %08lx\n", ++ p->port, led, selector, conf->rules); ++ *rules = conf->rules; ++ return 0; ++ } ++ } ++ ++ return -EINVAL; ++} ++ ++/* mv88e6xxx_led_get_selector() - get the appropriate LED mode selector ++ * @p: port state container ++ * @led: LED number, 0 or 1 ++ * @fiber: the link is connected to fiber such as SFP ++ * @rules: LED status flags from the LED classdev core ++ * @selector: fill in the selector in this parameter with an OR operation ++ */ ++static int mv88e6xxx_led_get_selector(struct mv88e6xxx_port *p, int led, ++ bool fiber, unsigned long rules, u16 *selector) ++{ ++ int err; ++ ++ /* What happens here is that we first try to locate a trigger with solid ++ * indicator (such as LED is on for a 1000 link) else we try a second ++ * sweep to find something suitable with a trigger that will blink on ++ * activity. ++ */ ++ err = mv88e6xxx_led_match_selector(p, led, false, fiber, rules, selector); ++ if (err) ++ return mv88e6xxx_led_match_selector(p, led, true, fiber, rules, selector); ++ ++ return 0; ++} ++ ++/* Sets up the hardware blinking period */ ++static int mv88e6xxx_led_set_blinking_period(struct mv88e6xxx_port *p, int led, ++ unsigned long delay_on, unsigned long delay_off) ++{ ++ unsigned long period; ++ u16 reg; ++ ++ period = delay_on + delay_off; ++ ++ reg = 0; ++ ++ switch (period) { ++ case 21: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_21MS; ++ break; ++ case 42: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_42MS; ++ break; ++ case 84: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_84MS; ++ break; ++ case 168: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_168MS; ++ break; ++ case 336: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_336MS; ++ break; ++ case 672: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_672MS; ++ break; ++ default: ++ /* Fall back to software blinking */ ++ return -EINVAL; ++ } ++ ++ /* This is essentially PWM duty cycle: how long time of the period ++ * will the LED be on. Zero isn't great in most cases. ++ */ ++ switch (delay_on) { ++ case 0: ++ /* This is usually pretty useless and will make the LED look OFF */ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_NONE; ++ break; ++ case 21: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_21MS; ++ break; ++ case 42: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_42MS; ++ break; ++ case 84: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_84MS; ++ break; ++ case 168: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_168MS; ++ break; ++ default: ++ /* Just use something non-zero */ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_21MS; ++ break; ++ } ++ ++ /* Set up blink rate */ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_POINTER_STRETCH_BLINK; ++ ++ return mv88e6xxx_port_led_write(p->chip, p->port, reg); ++} ++ ++static int mv88e6xxx_led_blink_set(struct mv88e6xxx_port *p, int led, ++ unsigned long *delay_on, unsigned long *delay_off) ++{ ++ u16 reg; ++ int err; ++ ++ /* Choose a sensible default 336 ms (~3 Hz) */ ++ if ((*delay_on == 0) && (*delay_off == 0)) { ++ *delay_on = 168; ++ *delay_off = 168; ++ } ++ ++ /* No off delay is just on */ ++ if (*delay_off == 0) ++ return mv88e6xxx_led_brightness_set(p, led, 1); ++ ++ err = mv88e6xxx_led_set_blinking_period(p, led, *delay_on, *delay_off); ++ if (err) ++ return err; ++ ++ err = mv88e6xxx_port_led_read(p->chip, p->port, ++ MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL, ++ ®); ++ if (err) ++ return err; ++ ++ if (led == 1) ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK; ++ else ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK; ++ ++ /* This will select the forced blinking status */ ++ if (led == 1) ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED1_SELD; ++ else ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED0_SELD; ++ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL; ++ ++ return mv88e6xxx_port_led_write(p->chip, p->port, reg); ++} ++ ++static int mv88e6xxx_led0_blink_set(struct led_classdev *ldev, ++ unsigned long *delay_on, ++ unsigned long *delay_off) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_blink_set(p, 0, delay_on, delay_off); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++static int mv88e6xxx_led1_blink_set(struct led_classdev *ldev, ++ unsigned long *delay_on, ++ unsigned long *delay_off) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_blink_set(p, 1, delay_on, delay_off); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++static int ++mv88e6xxx_led0_hw_control_is_supported(struct led_classdev *ldev, unsigned long rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ u16 selector = 0; ++ ++ return mv88e6xxx_led_get_selector(p, 0, p->fiber, rules, &selector); ++} ++ ++static int ++mv88e6xxx_led1_hw_control_is_supported(struct led_classdev *ldev, unsigned long rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ u16 selector = 0; ++ ++ return mv88e6xxx_led_get_selector(p, 1, p->fiber, rules, &selector); ++} ++ ++static int mv88e6xxx_led_hw_control_set(struct mv88e6xxx_port *p, ++ int led, unsigned long rules) ++{ ++ u16 reg; ++ int err; ++ ++ err = mv88e6xxx_port_led_read(p->chip, p->port, ++ MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL, ++ ®); ++ if (err) ++ return err; ++ ++ if (led == 1) ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK; ++ else ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK; ++ ++ err = mv88e6xxx_led_get_selector(p, led, p->fiber, rules, ®); ++ if (err) ++ return err; ++ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL; ++ ++ if (led == 0) ++ dev_dbg(p->chip->dev, "LED 0 hw control on port %d trigger selector 0x%02x\n", ++ p->port, ++ (unsigned int)(reg & MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK)); ++ else ++ dev_dbg(p->chip->dev, "LED 1 hw control on port %d trigger selector 0x%02x\n", ++ p->port, ++ (unsigned int)(reg & MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK) >> 4); ++ ++ return mv88e6xxx_port_led_write(p->chip, p->port, reg); ++} ++ ++static int ++mv88e6xxx_led_hw_control_get(struct mv88e6xxx_port *p, int led, unsigned long *rules) ++{ ++ u16 val; ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_port_led_read(p->chip, p->port, ++ MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL, &val); ++ mv88e6xxx_reg_unlock(p->chip); ++ if (err) ++ return err; ++ ++ /* Mask out the selector bits for this port */ ++ if (led == 1) { ++ val &= MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK; ++ /* It's forced blinking/OFF/ON */ ++ if (val == MV88E6XXX_PORT_LED_CONTROL_LED1_SELD || ++ val == MV88E6XXX_PORT_LED_CONTROL_LED1_SELE || ++ val == MV88E6XXX_PORT_LED_CONTROL_LED1_SELF) { ++ *rules = 0; ++ return 0; ++ } ++ } else { ++ val &= MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK; ++ /* It's forced blinking/OFF/ON */ ++ if (val == MV88E6XXX_PORT_LED_CONTROL_LED0_SELD || ++ val == MV88E6XXX_PORT_LED_CONTROL_LED0_SELE || ++ val == MV88E6XXX_PORT_LED_CONTROL_LED0_SELF) { ++ *rules = 0; ++ return 0; ++ } ++ } ++ ++ err = mv88e6xxx_led_match_rule(p, val, led, rules); ++ if (!err) ++ return 0; ++ ++ dev_dbg(p->chip->dev, "couldn't find matching selector for %04x\n", val); ++ *rules = 0; ++ return 0; ++} ++ ++static int ++mv88e6xxx_led0_hw_control_set(struct led_classdev *ldev, unsigned long rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_hw_control_set(p, 0, rules); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++static int ++mv88e6xxx_led1_hw_control_set(struct led_classdev *ldev, unsigned long rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_hw_control_set(p, 1, rules); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++static int ++mv88e6xxx_led0_hw_control_get(struct led_classdev *ldev, unsigned long *rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ ++ return mv88e6xxx_led_hw_control_get(p, 0, rules); ++} ++ ++static int ++mv88e6xxx_led1_hw_control_get(struct led_classdev *ldev, unsigned long *rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ ++ return mv88e6xxx_led_hw_control_get(p, 1, rules); ++} ++ ++static struct device *mv88e6xxx_led_hw_control_get_device(struct mv88e6xxx_port *p) ++{ ++ struct dsa_port *dp; ++ ++ dp = dsa_to_port(p->chip->ds, p->port); ++ if (!dp) ++ return NULL; ++ if (dp->slave) ++ return &dp->slave->dev; ++ return NULL; ++} ++ ++static struct device * ++mv88e6xxx_led0_hw_control_get_device(struct led_classdev *ldev) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ ++ return mv88e6xxx_led_hw_control_get_device(p); ++} ++ ++static struct device * ++mv88e6xxx_led1_hw_control_get_device(struct led_classdev *ldev) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ ++ return mv88e6xxx_led_hw_control_get_device(p); ++} ++ ++int mv88e6xxx_port_setup_leds(struct mv88e6xxx_chip *chip, int port) ++{ ++ struct fwnode_handle *led = NULL, *leds = NULL; ++ struct led_init_data init_data = { }; ++ enum led_default_state state; ++ struct mv88e6xxx_port *p; ++ struct led_classdev *l; ++ struct device *dev; ++ u32 led_num; ++ int ret; ++ ++ /* LEDs are on ports 1,2,3,4, 5 and 6 (index 0..5), no more */ ++ if (port > 5) ++ return -EOPNOTSUPP; ++ ++ p = &chip->ports[port]; ++ if (!p->fwnode) ++ return 0; ++ ++ dev = chip->dev; ++ ++ leds = fwnode_get_named_child_node(p->fwnode, "leds"); ++ if (!leds) { ++ dev_dbg(dev, "No Leds node specified in device tree for port %d!\n", ++ port); ++ return 0; ++ } ++ ++ fwnode_for_each_child_node(leds, led) { ++ /* Reg represent the led number of the port, max 2 ++ * LEDs can be connected to each port, in some designs ++ * only one LED is connected. ++ */ ++ if (fwnode_property_read_u32(led, "reg", &led_num)) ++ continue; ++ if (led_num > 1) { ++ dev_err(dev, "invalid LED specified port %d\n", port); ++ return -EINVAL; ++ } ++ ++ if (led_num == 0) ++ l = &p->led0; ++ else ++ l = &p->led1; ++ ++ state = led_init_default_state_get(led); ++ switch (state) { ++ case LEDS_DEFSTATE_ON: ++ l->brightness = 1; ++ mv88e6xxx_led_brightness_set(p, led_num, 1); ++ break; ++ case LEDS_DEFSTATE_KEEP: ++ break; ++ default: ++ l->brightness = 0; ++ mv88e6xxx_led_brightness_set(p, led_num, 0); ++ } ++ ++ l->max_brightness = 1; ++ if (led_num == 0) { ++ l->brightness_set_blocking = mv88e6xxx_led0_brightness_set_blocking; ++ l->blink_set = mv88e6xxx_led0_blink_set; ++ l->hw_control_is_supported = mv88e6xxx_led0_hw_control_is_supported; ++ l->hw_control_set = mv88e6xxx_led0_hw_control_set; ++ l->hw_control_get = mv88e6xxx_led0_hw_control_get; ++ l->hw_control_get_device = mv88e6xxx_led0_hw_control_get_device; ++ } else { ++ l->brightness_set_blocking = mv88e6xxx_led1_brightness_set_blocking; ++ l->blink_set = mv88e6xxx_led1_blink_set; ++ l->hw_control_is_supported = mv88e6xxx_led1_hw_control_is_supported; ++ l->hw_control_set = mv88e6xxx_led1_hw_control_set; ++ l->hw_control_get = mv88e6xxx_led1_hw_control_get; ++ l->hw_control_get_device = mv88e6xxx_led1_hw_control_get_device; ++ } ++ l->hw_control_trigger = "netdev"; ++ ++ init_data.default_label = ":port"; ++ init_data.fwnode = led; ++ init_data.devname_mandatory = true; ++ init_data.devicename = kasprintf(GFP_KERNEL, "%s:0%d:0%d", chip->info->name, ++ port, led_num); ++ if (!init_data.devicename) ++ return -ENOMEM; ++ ++ ret = devm_led_classdev_register_ext(dev, l, &init_data); ++ kfree(init_data.devicename); ++ ++ if (ret) { ++ dev_err(dev, "Failed to init LED %d for port %d", led_num, port); ++ return ret; ++ } ++ } ++ ++ return 0; ++} +--- a/drivers/net/dsa/mv88e6xxx/port.c ++++ b/drivers/net/dsa/mv88e6xxx/port.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + + #include "chip.h" + #include "global2.h" +--- a/drivers/net/dsa/mv88e6xxx/port.h ++++ b/drivers/net/dsa/mv88e6xxx/port.h +@@ -309,6 +309,130 @@ + /* Offset 0x13: OutFiltered Counter */ + #define MV88E6XXX_PORT_OUT_FILTERED 0x13 + ++/* Offset 0x16: LED Control */ ++#define MV88E6XXX_PORT_LED_CONTROL 0x16 ++#define MV88E6XXX_PORT_LED_CONTROL_UPDATE BIT(15) ++#define MV88E6XXX_PORT_LED_CONTROL_POINTER_MASK GENMASK(14, 12) ++#define MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL (0x00 << 12) /* Control for LED 0 and 1 */ ++#define MV88E6XXX_PORT_LED_CONTROL_POINTER_STRETCH_BLINK (0x06 << 12) /* Stetch and Blink Rate */ ++#define MV88E6XXX_PORT_LED_CONTROL_POINTER_CNTL_SPECIAL (0x07 << 12) /* Control for the Port's Special LED */ ++#define MV88E6XXX_PORT_LED_CONTROL_DATA_MASK GENMASK(10, 0) ++/* Selection masks valid for either port 1,2,3,4 or 5 */ ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK GENMASK(3, 0) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK GENMASK(7, 4) ++/* Selection control for LED 0 and 1, ports 5 and 6 only has LED 0 ++ * Bits Function ++ * 0..3 LED 0 control selector on ports 1-5 ++ * 4..7 LED 1 control selector on ports 1-4 on port 5 this controls LED 0 of port 6 ++ * ++ * Sel Port LED Function for the 6352 family: ++ * 0 1-4 0 Link/Act/Speed by Blink Rate (off=no link, on=link, blink=activity, blink speed=link speed) ++ * 1-4 1 Port 2's Special LED ++ * 5-6 0 Port 5 Link/Act (off=no link, on=link, blink=activity) ++ * 5-6 1 Port 6 Link/Act (off=no link, on=link 1000, blink=activity) ++ * 1 1-4 0 100/1000 Link/Act (off=no link, on=100 or 1000 link, blink=activity) ++ * 1-4 1 10/100 Link Act (off=no link, on=10 or 100 link, blink=activity) ++ * 5-6 0 Fiber 100 Link/Act (off=no link, on=link 100, blink=activity) ++ * 5-6 1 Fiber 1000 Link/Act (off=no link, on=link 1000, blink=activity) ++ * 2 1-4 0 1000 Link/Act (off=no link, on=link 1000, blink=activity) ++ * 1-4 1 10/100 Link/Act (off=no link, on=10 or 100 link, blink=activity) ++ * 5-6 0 Fiber 1000 Link/Act (off=no link, on=link 1000, blink=activity) ++ * 5-6 1 Fiber 100 Link/Act (off=no link, on=link 100, blink=activity) ++ * 3 1-4 0 Link/Act (off=no link, on=link, blink=activity) ++ * 1-4 1 1000 Link (off=no link, on=1000 link) ++ * 5-6 0 Port 0's Special LED ++ * 5-6 1 Fiber Link (off=no link, on=link) ++ * 4 1-4 0 Port 0's Special LED ++ * 1-4 1 Port 1's Special LED ++ * 5-6 0 Port 1's Special LED ++ * 5-6 1 Port 5 Link/Act (off=no link, on=link, blink=activity) ++ * 5 1-4 0 Reserved ++ * 1-4 1 Reserved ++ * 5-6 0 Port 2's Special LED ++ * 5-6 1 Port 6 Link (off=no link, on=link) ++ * 6 1-4 0 Duplex/Collision (off=half-duplex,on=full-duplex,blink=collision) ++ * 1-4 1 10/1000 Link/Act (off=no link, on=10 or 1000 link, blink=activity) ++ * 5-6 0 Port 5 Duplex/Collision (off=half-duplex, on=full-duplex, blink=col) ++ * 5-6 1 Port 6 Duplex/Collision (off=half-duplex, on=full-duplex, blink=col) ++ * 7 1-4 0 10/1000 Link/Act (off=no link, on=10 or 1000 link, blink=activity) ++ * 1-4 1 10/1000 Link (off=no link, on=10 or 1000 link) ++ * 5-6 0 Port 5 Link/Act/Speed by Blink rate (off=no link, on=link, blink=activity, blink speed=link speed) ++ * 5-6 1 Port 6 Link/Act/Speed by Blink rate (off=no link, on=link, blink=activity, blink speed=link speed) ++ * 8 1-4 0 Link (off=no link, on=link) ++ * 1-4 1 Activity (off=no link, blink on=activity) ++ * 5-6 0 Port 6 Link/Act (off=no link, on=link, blink=activity) ++ * 5-6 1 Port 0's Special LED ++ * 9 1-4 0 10 Link (off=no link, on=10 link) ++ * 1-4 1 100 Link (off=no link, on=100 link) ++ * 5-6 0 Reserved ++ * 5-6 1 Port 1's Special LED ++ * a 1-4 0 10 Link/Act (off=no link, on=10 link, blink=activity) ++ * 1-4 1 100 Link/Act (off=no link, on=100 link, blink=activity) ++ * 5-6 0 Reserved ++ * 5-6 1 Port 2's Special LED ++ * b 1-4 0 100/1000 Link (off=no link, on=100 or 1000 link) ++ * 1-4 1 10/100 Link (off=no link, on=100 link, blink=activity) ++ * 5-6 0 Reserved ++ * 5-6 1 Reserved ++ * c * * PTP Act (blink on=PTP activity) ++ * d * * Force Blink ++ * e * * Force Off ++ * f * * Force On ++ */ ++/* Select LED0 output */ ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL0 0x0 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL1 0x1 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL2 0x2 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL3 0x3 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL4 0x4 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL5 0x5 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL6 0x6 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL7 0x7 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL8 0x8 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL9 0x9 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELA 0xa ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELB 0xb ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELC 0xc ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELD 0xd ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELE 0xe ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELF 0xf ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL0 (0x0 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL1 (0x1 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL2 (0x2 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL3 (0x3 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL4 (0x4 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL5 (0x5 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL6 (0x6 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL7 (0x7 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL8 (0x8 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL9 (0x9 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELA (0xa << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELB (0xb << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELC (0xc << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELD (0xd << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELE (0xe << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELF (0xf << 4) ++/* Stretch and Blink Rate Control (Index 0x06 of LED Control) */ ++/* Pulse Stretch Selection for all LED's on this port */ ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_NONE (0 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_21MS (1 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_42MS (2 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_84MS (3 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_168MS (4 << 4) ++/* Blink Rate Selection for all LEDs on this port */ ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_21MS 0 ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_42MS 1 ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_84MS 2 ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_168MS 3 ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_336MS 4 ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_672MS 5 ++ /* Control for Special LED (Index 0x7 of LED Control on Port0) */ ++#define MV88E6XXX_PORT_LED_CONTROL_0x07_P0_LAN_LINKACT_SHIFT 0 /* bits 6:0 LAN Link Activity LED */ ++/* Control for Special LED (Index 0x7 of LED Control on Port 1) */ ++#define MV88E6XXX_PORT_LED_CONTROL_0x07_P1_WAN_LINKACT_SHIFT 0 /* bits 6:0 WAN Link Activity LED */ ++/* Control for Special LED (Index 0x7 of LED Control on Port 2) */ ++#define MV88E6XXX_PORT_LED_CONTROL_0x07_P2_PTP_ACT 0 /* bits 6:0 PTP Activity */ ++ + /* Offset 0x18: IEEE Priority Mapping Table */ + #define MV88E6390_PORT_IEEE_PRIO_MAP_TABLE 0x18 + #define MV88E6390_PORT_IEEE_PRIO_MAP_TABLE_UPDATE 0x8000 +@@ -457,6 +581,15 @@ int mv88e6393x_port_set_cmode(struct mv8 + phy_interface_t mode); + int mv88e6185_port_get_cmode(struct mv88e6xxx_chip *chip, int port, u8 *cmode); + int mv88e6352_port_get_cmode(struct mv88e6xxx_chip *chip, int port, u8 *cmode); ++#ifdef CONFIG_NET_DSA_MV88E6XXX_LEDS ++int mv88e6xxx_port_setup_leds(struct mv88e6xxx_chip *chip, int port); ++#else ++static inline int mv88e6xxx_port_setup_leds(struct mv88e6xxx_chip *chip, ++ int port) ++{ ++ return 0; ++} ++#endif + int mv88e6xxx_port_drop_untagged(struct mv88e6xxx_chip *chip, int port, + bool drop_untagged); + int mv88e6xxx_port_set_map_da(struct mv88e6xxx_chip *chip, int port, bool map); diff --git a/target/linux/generic/config-6.6 b/target/linux/generic/config-6.6 index 13cde24e88..124bda430d 100644 --- a/target/linux/generic/config-6.6 +++ b/target/linux/generic/config-6.6 @@ -3990,6 +3990,7 @@ CONFIG_NET_CORE=y # CONFIG_NET_DSA_MT7530 is not set # CONFIG_NET_DSA_MV88E6060 is not set # CONFIG_NET_DSA_MV88E6XXX is not set +# CONFIG_NET_DSA_MV88E6XXX_LEDS is not set # CONFIG_NET_DSA_MV88E6XXX_PTP is not set # CONFIG_NET_DSA_QCA8K is not set # CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT is not set diff --git a/target/linux/generic/hack-6.6/711-net-dsa-mv88e6xxx-disable-ATU-violation.patch b/target/linux/generic/hack-6.6/711-net-dsa-mv88e6xxx-disable-ATU-violation.patch index dbf1da04ef..bf93a87e02 100644 --- a/target/linux/generic/hack-6.6/711-net-dsa-mv88e6xxx-disable-ATU-violation.patch +++ b/target/linux/generic/hack-6.6/711-net-dsa-mv88e6xxx-disable-ATU-violation.patch @@ -9,7 +9,7 @@ Subject: [PATCH] net/dsa/mv88e6xxx: disable ATU violation --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c -@@ -3375,6 +3375,9 @@ static int mv88e6xxx_setup_port(struct m +@@ -3405,6 +3405,9 @@ static int mv88e6xxx_setup_port(struct m else reg = 1 << port; diff --git a/target/linux/generic/pending-6.6/768-net-dsa-mv88e6xxx-Request-assisted-learning-on-CPU-port.patch b/target/linux/generic/pending-6.6/768-net-dsa-mv88e6xxx-Request-assisted-learning-on-CPU-port.patch deleted file mode 100644 index 3f3d7572e0..0000000000 --- a/target/linux/generic/pending-6.6/768-net-dsa-mv88e6xxx-Request-assisted-learning-on-CPU-port.patch +++ /dev/null @@ -1,27 +0,0 @@ -From: Tobias Waldekranz -Subject: [RFC net-next 7/7] net: dsa: mv88e6xxx: Request assisted learning on CPU port -Date: Sat, 16 Jan 2021 02:25:15 +0100 -Archived-At: - -While the hardware is capable of performing learning on the CPU port, -it requires alot of additions to the bridge's forwarding path in order -to handle multi-destination traffic correctly. - -Until that is in place, opt for the next best thing and let DSA sync -the relevant addresses down to the hardware FDB. - -Signed-off-by: Tobias Waldekranz ---- - drivers/net/dsa/mv88e6xxx/chip.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/drivers/net/dsa/mv88e6xxx/chip.c -+++ b/drivers/net/dsa/mv88e6xxx/chip.c -@@ -6993,6 +6993,7 @@ static int mv88e6xxx_register_switch(str - ds->ops = &mv88e6xxx_switch_ops; - ds->ageing_time_min = chip->info->age_time_coeff; - ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX; -+ ds->assisted_learning_on_cpu_port = true; - - /* Some chips support up to 32, but that requires enabling the - * 5-bit port mode, which we do not support. 640k^W16 ought to diff --git a/target/linux/lantiq/ase/config-6.6 b/target/linux/lantiq/ase/config-6.6 index c4d8e575eb..f47a91c380 100644 --- a/target/linux/lantiq/ase/config-6.6 +++ b/target/linux/lantiq/ase/config-6.6 @@ -1,10 +1,10 @@ -CONFIG_ADM6996_PHY=y CONFIG_CPU_MIPS32_R1=y # CONFIG_CPU_MIPS32_R2 is not set CONFIG_CPU_MIPSR1=y CONFIG_CRC16=y CONFIG_CRYPTO_DEFLATE=y CONFIG_FIRMWARE_MEMMAP=y +CONFIG_FORCE_NR_CPUS=y CONFIG_GENERIC_ALLOCATOR=y CONFIG_GPIO_GENERIC=y CONFIG_GPIO_GENERIC_PLATFORM=y @@ -15,7 +15,6 @@ CONFIG_NLS=y CONFIG_SGL_ALLOC=y CONFIG_SOC_AMAZON_SE=y # CONFIG_SOC_XWAY is not set -CONFIG_SWCONFIG=y CONFIG_TARGET_ISA_REV=1 CONFIG_USB=y CONFIG_USB_COMMON=y diff --git a/target/linux/mediatek/dts/mt7986a-asus-tuf-ax6000.dts b/target/linux/mediatek/dts/mt7986a-asus-tuf-ax6000.dts index 891d56853b..957d8deebb 100644 --- a/target/linux/mediatek/dts/mt7986a-asus-tuf-ax6000.dts +++ b/target/linux/mediatek/dts/mt7986a-asus-tuf-ax6000.dts @@ -70,6 +70,16 @@ label = "blue:cover"; gpios = <&pio 20 GPIO_ACTIVE_HIGH>; }; + + cover-red { + label = "red:cover"; + gpios = <&pio 21 GPIO_ACTIVE_HIGH>; + }; + + cover-green { + label = "green:cover"; + gpios = <&pio 22 GPIO_ACTIVE_HIGH>; + }; }; reg_3p3v: regulator-3p3v { diff --git a/target/linux/ramips/dts/mt7621_mikrotik.dtsi b/target/linux/ramips/dts/mt7621_mikrotik.dtsi index ace194c6d6..67892cc1a0 100644 --- a/target/linux/ramips/dts/mt7621_mikrotik.dtsi +++ b/target/linux/ramips/dts/mt7621_mikrotik.dtsi @@ -49,6 +49,14 @@ hard_config { read-only; + + nvmem-layout { + compatible = "mikrotik,routerboot-nvmem"; + + macaddr_hard: base-mac-address { + #nvmem-cell-cells = <1>; + }; + }; }; partition@10000 { diff --git a/target/linux/ramips/dts/mt7621_mikrotik_ltap-2hnd.dts b/target/linux/ramips/dts/mt7621_mikrotik_ltap-2hnd.dts index b5e38071f1..a3e3d8f4ce 100644 --- a/target/linux/ramips/dts/mt7621_mikrotik_ltap-2hnd.dts +++ b/target/linux/ramips/dts/mt7621_mikrotik_ltap-2hnd.dts @@ -11,6 +11,7 @@ led-failsafe = &led_usr; led-running = &led_usr; led-upgrade = &led_usr; + label-mac-device = ðernet; }; ath9k-leds { @@ -128,6 +129,9 @@ ðernet { pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; &switch0 { @@ -146,6 +150,8 @@ compatible = "pci168c,0030"; reg = <0x0000 0 0 0 0>; qca,no-eeprom; + nvmem-cells = <&macaddr_hard 1>; + nvmem-cell-names = "mac-address"; gpio-controller; #gpio-cells = <2>; }; diff --git a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-750gr3.dts b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-750gr3.dts index faa4e53f09..6357dceb6d 100644 --- a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-750gr3.dts +++ b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-750gr3.dts @@ -11,6 +11,7 @@ led-failsafe = &led_usr; led-running = &led_usr; led-upgrade = &led_usr; + label-mac-device = &gmac1; }; leds { @@ -40,6 +41,9 @@ status = "okay"; label = "wan"; phy-handle = <ðphy0>; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; ðphy0 { diff --git a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-760igs.dts b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-760igs.dts index 8b88cfe0a3..c9d07cf96c 100644 --- a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-760igs.dts +++ b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-760igs.dts @@ -11,6 +11,7 @@ led-failsafe = &led_pwr; led-running = &led_pwr; led-upgrade = &led_pwr; + label-mac-device = &port0; }; leds { @@ -51,6 +52,9 @@ label = "sfp"; phy-mode = "rgmii-rxid"; phy-handle = <&ephy7>; + + nvmem-cells = <&macaddr_hard 5>; + nvmem-cell-names = "mac-address"; }; &i2c { diff --git a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-7xx.dtsi b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-7xx.dtsi index b8fae51c3b..cdca47f8b8 100644 --- a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-7xx.dtsi +++ b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-7xx.dtsi @@ -40,29 +40,44 @@ &switch0 { ports { - port@0 { + port0: port@0 { status = "okay"; label = "wan"; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; port@1 { status = "okay"; label = "lan2"; + + nvmem-cells = <&macaddr_hard 1>; + nvmem-cell-names = "mac-address"; }; port@2 { status = "okay"; label = "lan3"; + + nvmem-cells = <&macaddr_hard 2>; + nvmem-cell-names = "mac-address"; }; port@3 { status = "okay"; label = "lan4"; + + nvmem-cells = <&macaddr_hard 3>; + nvmem-cell-names = "mac-address"; }; port@4 { status = "okay"; label = "lan5"; + + nvmem-cells = <&macaddr_hard 4>; + nvmem-cell-names = "mac-address"; }; }; }; diff --git a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m11g.dts b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m11g.dts index 5f9ee90e7c..89ef5fb3fd 100644 --- a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m11g.dts +++ b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m11g.dts @@ -9,6 +9,7 @@ led-failsafe = &led_usr; led-running = &led_usr; led-upgrade = &led_usr; + label-mac-device = ðernet; }; leds { @@ -68,6 +69,9 @@ ðernet { pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; &switch0 { @@ -75,6 +79,9 @@ port@0 { status = "okay"; label = "lan"; + + nvmem-cells = <&macaddr_hard 1>; + nvmem-cell-names = "mac-address"; }; }; }; diff --git a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m33g.dts b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m33g.dts index 5e76261529..e26d3cee2e 100644 --- a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m33g.dts +++ b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-m33g.dts @@ -9,6 +9,7 @@ led-failsafe = &led_usr; led-running = &led_usr; led-upgrade = &led_usr; + label-mac-device = &gmac1; }; leds { @@ -94,6 +95,9 @@ status = "okay"; label = "wan"; phy-handle = <ðphy0>; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; ðphy0 { @@ -105,11 +109,17 @@ port@1 { status = "okay"; label = "lan1"; + + nvmem-cells = <&macaddr_hard 1>; + nvmem-cell-names = "mac-address"; }; port@2 { status = "okay"; label = "lan2"; + + nvmem-cells = <&macaddr_hard 2>; + nvmem-cell-names = "mac-address"; }; }; }; diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 6bc0222174..2c0e090876 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -301,10 +301,6 @@ ramips_setup_macs() wan_mac=$(mtd_get_mac_ascii Config wan_hwaddr) label_mac=$lan_mac ;; - mikrotik,ltap-2hnd) - label_mac=$(cat "/sys/firmware/mikrotik/hard_config/mac_base") - lan_mac=$label_mac - ;; tplink,er605-v2) CI_UBIPART="firmware" label_mac=$(mtd_get_mac_uci_config_ubi "tddp") @@ -316,14 +312,6 @@ ramips_setup_macs() wwan_mac=$(macaddr_add $label_mac 1) ucidef_set_interface "wwan0" device "/dev/cdc-wdm0" protocol "qmi" macaddr "$wwan_mac" ;; - mikrotik,routerboard-750gr3|\ - mikrotik,routerboard-760igs|\ - mikrotik,routerboard-m11g|\ - mikrotik,routerboard-m33g) - label_mac=$(cat "/sys/firmware/mikrotik/hard_config/mac_base") - wan_mac=$label_mac - lan_mac=$(macaddr_add $label_mac 1) - ;; ruijie,rg-ew1200g-pro-v1.1) lan_mac=$(mtd_get_mac_ascii product_info ethaddr) wan_mac=$(macaddr_add "$lan_mac" 8) diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 0bf5e85cd0..a334d1a5a0 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -4,26 +4,13 @@ . /lib/functions/caldata.sh -caldata_mikrotik_ath9k() { - local offset=$(($1)) - local count=$(($2)) - local macaddr=$3 - local wlan_data="/sys/firmware/mikrotik/hard_config/wlan_data" - - caldata_from_file $wlan_data $offset $count /tmp/$FIRMWARE - ath9k_patch_mac "$macaddr" /tmp/$FIRMWARE - caldata_sysfsload_from_file /tmp/$FIRMWARE 0x0 $count - rm -f /tmp/$FIRMWARE -} - board=$(board_name) case "$FIRMWARE" in "ath9k-eeprom-pci-0000:01:00.0.bin") case $board in mikrotik,ltap-2hnd) - mac_base="$(cat /sys/firmware/mikrotik/hard_config/mac_base)" - caldata_mikrotik_ath9k 0x5000 0x440 $(macaddr_add "$mac_base" 1) + caldata_sysfsload_from_file "/sys/firmware/mikrotik/hard_config/wlan_data" 0x5000 0x440 ;; *) caldata_die "board $board is not supported yet" diff --git a/target/linux/ramips/mt7621/config-6.6 b/target/linux/ramips/mt7621/config-6.6 index adbb7c8465..5e10f03ac1 100644 --- a/target/linux/ramips/mt7621/config-6.6 +++ b/target/linux/ramips/mt7621/config-6.6 @@ -202,7 +202,7 @@ CONFIG_NO_HZ_IDLE=y CONFIG_NR_CPUS=4 CONFIG_NVMEM=y CONFIG_NVMEM_LAYOUTS=y -# CONFIG_NVMEM_LAYOUT_MIKROTIK is not set +CONFIG_NVMEM_LAYOUT_MIKROTIK=y CONFIG_NVMEM_LAYOUT_U_BOOT_ENV=y CONFIG_OF=y CONFIG_OF_ADDRESS=y diff --git a/target/linux/ramips/patches-6.6/821-SPI-ralink-add-Ralink-SoC-spi-driver.patch b/target/linux/ramips/patches-6.6/821-SPI-ralink-add-Ralink-SoC-spi-driver.patch index 6760d9f56c..318039fb4c 100644 --- a/target/linux/ramips/patches-6.6/821-SPI-ralink-add-Ralink-SoC-spi-driver.patch +++ b/target/linux/ramips/patches-6.6/821-SPI-ralink-add-Ralink-SoC-spi-driver.patch @@ -41,7 +41,7 @@ Acked-by: John Crispin obj-$(CONFIG_SPI_SC18IS602) += spi-sc18is602.o --- /dev/null +++ b/drivers/spi/spi-rt2880.c -@@ -0,0 +1,535 @@ +@@ -0,0 +1,519 @@ +/* + * spi-rt2880.c -- Ralink RT288x/RT305x SPI controller driver + * @@ -66,7 +66,6 @@ Acked-by: John Crispin +#include +#include +#include -+#include + +#define DRIVER_NAME "spi-rt2880" + @@ -333,18 +332,6 @@ Acked-by: John Crispin + return err; +} + -+/* copy from spi.c */ -+static void spi_set_cs(struct spi_device *spi, bool enable) -+{ -+ if (spi->mode & SPI_CS_HIGH) -+ enable = !enable; -+ -+ if (spi->cs_gpiod) -+ gpiod_set_value(spi->cs_gpiod, !enable); -+ else if (spi->master->set_cs) -+ spi->master->set_cs(spi, !enable); -+} -+ +static int rt2880_spi_setup(struct spi_device *spi) +{ + struct spi_master *master = spi->master; @@ -401,9 +388,6 @@ Acked-by: John Crispin + if (reg != old_reg) + rt2880_spi_write(rs, arbit_off, reg); + -+ /* deselected the spi device */ -+ spi_set_cs(spi, false); -+ + rt2880_dump_reg(master); + + return 0; diff --git a/target/linux/rockchip/patches-6.6/111-05-clk-rockchip-fix-error-for-unknown-clocks.patch b/target/linux/rockchip/patches-6.6/111-05-clk-rockchip-fix-error-for-unknown-clocks.patch new file mode 100644 index 0000000000..4db2b80674 --- /dev/null +++ b/target/linux/rockchip/patches-6.6/111-05-clk-rockchip-fix-error-for-unknown-clocks.patch @@ -0,0 +1,49 @@ +From: Sebastian Reichel +To: Michael Turquette , + Stephen Boyd , + linux-clk@vger.kernel.org +Cc: Elaine Zhang , + Kever Yang , + Heiko Stuebner , + Rob Herring , + Krzysztof Kozlowski , + Conor Dooley , + huangtao@rock-chips.com, andy.yan@rock-chips.com, + Michal Tomek , Ilya K , + Chad LeClair , + devicetree@vger.kernel.org, linux-rockchip@lists.infradead.org, + Sebastian Reichel , + kernel@collabora.com +Subject: [PATCH v9 5/7] clk: rockchip: fix error for unknown clocks +Date: Mon, 25 Mar 2024 20:33:36 +0100 [thread overview] +Message-ID: <20240325193609.237182-6-sebastian.reichel@collabora.com> (raw) +In-Reply-To: <20240325193609.237182-1-sebastian.reichel@collabora.com> + +There is a clk == NULL check after the switch to check for +unsupported clk types. Since clk is re-assigned in a loop, +this check is useless right now for anything but the first +round. Let's fix this up by assigning clk = NULL in the +loop before the switch statement. + +Signed-off-by: Sebastian Reichel +--- + drivers/clk/rockchip/clk.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/clk/rockchip/clk.c ++++ b/drivers/clk/rockchip/clk.c +@@ -444,12 +444,13 @@ void rockchip_clk_register_branches(stru + struct rockchip_clk_branch *list, + unsigned int nr_clk) + { +- struct clk *clk = NULL; ++ struct clk *clk; + unsigned int idx; + unsigned long flags; + + for (idx = 0; idx < nr_clk; idx++, list++) { + flags = list->flags; ++ clk = NULL; + + /* catch simple muxes */ + switch (list->branch_type) { diff --git a/toolchain/binutils/Config.in b/toolchain/binutils/Config.in index 93ef5d82c8..e2721b1eaf 100644 --- a/toolchain/binutils/Config.in +++ b/toolchain/binutils/Config.in @@ -6,26 +6,10 @@ choice help Select the version of binutils you wish to use. - config BINUTILS_USE_VERSION_2_37 - bool "Binutils 2.37" - select BINUTILS_VERSION_2_37 - - config BINUTILS_USE_VERSION_2_38 - bool "Binutils 2.38" - select BINUTILS_VERSION_2_38 - - config BINUTILS_USE_VERSION_2_39 - bool "Binutils 2.39" - select BINUTILS_VERSION_2_39 - config BINUTILS_USE_VERSION_2_40 bool "Binutils 2.40" select BINUTILS_VERSION_2_40 - config BINUTILS_USE_VERSION_2_41 - bool "Binutils 2.41" - select BINUTILS_VERSION_2_41 - config BINUTILS_USE_VERSION_2_42 bool "Binutils 2.42" select BINUTILS_VERSION_2_42 diff --git a/toolchain/binutils/Config.version b/toolchain/binutils/Config.version index 98605f469a..f616cddc2a 100644 --- a/toolchain/binutils/Config.version +++ b/toolchain/binutils/Config.version @@ -1,19 +1,7 @@ -config BINUTILS_VERSION_2_37 - bool - -config BINUTILS_VERSION_2_38 - bool - -config BINUTILS_VERSION_2_39 - bool - config BINUTILS_VERSION_2_40 bool -config BINUTILS_VERSION_2_41 - bool - config BINUTILS_VERSION_2_42 default y if !TOOLCHAINOPTS bool @@ -23,10 +11,6 @@ config BINUTILS_VERSION_2_43 config BINUTILS_VERSION string - default "2.37" if BINUTILS_VERSION_2_37 - default "2.38" if BINUTILS_VERSION_2_38 - default "2.39" if BINUTILS_VERSION_2_39 default "2.40" if BINUTILS_VERSION_2_40 - default "2.41" if BINUTILS_VERSION_2_41 default "2.42" if BINUTILS_VERSION_2_42 default "2.43.1" if BINUTILS_VERSION_2_43 diff --git a/toolchain/binutils/Makefile b/toolchain/binutils/Makefile index 92ec8ec7e3..63f0e07ccf 100644 --- a/toolchain/binutils/Makefile +++ b/toolchain/binutils/Makefile @@ -16,26 +16,10 @@ PKG_CPE_ID:=cpe:/a:gnu:binutils TAR_OPTIONS += --exclude='*.rej' -ifeq ($(PKG_VERSION),2.37) - PKG_HASH:=820d9724f020a3e69cb337893a0b63c2db161dadcb0e06fc11dc29eb1e84a32c -endif - -ifeq ($(PKG_VERSION),2.38) - PKG_HASH:=e316477a914f567eccc34d5d29785b8b0f5a10208d36bbacedcc39048ecfe024 -endif - -ifeq ($(PKG_VERSION),2.39) - PKG_HASH:=645c25f563b8adc0a81dbd6a41cffbf4d37083a382e02d5d3df4f65c09516d00 -endif - ifeq ($(PKG_VERSION),2.40) PKG_HASH:=0f8a4c272d7f17f369ded10a4aca28b8e304828e95526da482b0ccc4dfc9d8e1 endif -ifeq ($(PKG_VERSION),2.41) - PKG_HASH:=ae9a5789e23459e59606e6714723f2d3ffc31c03174191ef0d015bdf06007450 -endif - ifeq ($(PKG_VERSION),2.42) PKG_HASH:=f6e4d41fd5fc778b06b7891457b3620da5ecea1006c6a4a41ae998109f85a800 endif diff --git a/toolchain/binutils/patches/2.37/300-001_ld_makefile_patch.patch b/toolchain/binutils/patches/2.37/300-001_ld_makefile_patch.patch deleted file mode 100644 index f1cbb8198b..0000000000 --- a/toolchain/binutils/patches/2.37/300-001_ld_makefile_patch.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/ld/Makefile.am -+++ b/ld/Makefile.am -@@ -50,7 +50,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) - - EMUL = @EMUL@ - EMULATION_OFILES = @EMULATION_OFILES@ ---- a/ld/Makefile.in -+++ b/ld/Makefile.in -@@ -561,7 +561,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 diff --git a/toolchain/binutils/patches/2.37/400-mips_no_dynamic_linking_sym.patch b/toolchain/binutils/patches/2.37/400-mips_no_dynamic_linking_sym.patch deleted file mode 100644 index 070247ecf0..0000000000 --- a/toolchain/binutils/patches/2.37/400-mips_no_dynamic_linking_sym.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/bfd/elfxx-mips.c -+++ b/bfd/elfxx-mips.c -@@ -8057,6 +8057,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))) -@@ -8069,6 +8070,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) - { diff --git a/toolchain/binutils/patches/2.37/500-Change-default-emulation-for-mips64-linux.patch b/toolchain/binutils/patches/2.37/500-Change-default-emulation-for-mips64-linux.patch deleted file mode 100644 index c59843766e..0000000000 --- a/toolchain/binutils/patches/2.37/500-Change-default-emulation-for-mips64-linux.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/bfd/config.bfd -+++ b/bfd/config.bfd -@@ -891,12 +891,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,12 +530,12 @@ mips*-*-vxworks*) targ_emul=elf32ebmipvx - ;; - 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 diff --git a/toolchain/binutils/patches/2.37/600-Close_the_file_descriptor.patch b/toolchain/binutils/patches/2.37/600-Close_the_file_descriptor.patch deleted file mode 100644 index fef86a9cb5..0000000000 --- a/toolchain/binutils/patches/2.37/600-Close_the_file_descriptor.patch +++ /dev/null @@ -1,184 +0,0 @@ -From: H.J. Lu -Date: Mon, 26 Jul 2021 12:59:55 +0000 (-0700) -Subject: bfd: Close the file descriptor if there is no archive fd -X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=1c611b40e6bfc8029bff7696814330b5bc0ee5c0 - -bfd: Close the file descriptor if there is no archive fd - -Close the file descriptor if there is no archive plugin file descriptor -to avoid running out of file descriptors on thin archives with many -archive members. - -bfd/ - - PR ld/28138 - * plugin.c (bfd_plugin_close_file_descriptor): Close the file - descriptor there is no archive plugin file descriptor. - -ld/ - - PR ld/28138 - * testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for - native build. - - PR ld/28138 - * testsuite/ld-plugin/lto.exp: Run ld/28138 tests. - * testsuite/ld-plugin/pr28138.c: New file. - * testsuite/ld-plugin/pr28138-1.c: Likewise. - * testsuite/ld-plugin/pr28138-2.c: Likewise. - * testsuite/ld-plugin/pr28138-3.c: Likewise. - * testsuite/ld-plugin/pr28138-4.c: Likewise. - * testsuite/ld-plugin/pr28138-5.c: Likewise. - * testsuite/ld-plugin/pr28138-6.c: Likewise. - * testsuite/ld-plugin/pr28138-7.c: Likewise. - -(cherry picked from commit 5a98fb7513b559e20dfebdbaa2a471afda3b4742) -(cherry picked from commit 7dc37e1e1209c80e0bab784df6b6bac335e836f2) ---- - ---- a/bfd/plugin.c -+++ b/bfd/plugin.c -@@ -291,6 +291,14 @@ bfd_plugin_close_file_descriptor (bfd *a - && !bfd_is_thin_archive (abfd->my_archive)) - abfd = abfd->my_archive; - -+ /* Close the file descriptor if there is no archive plugin file -+ descriptor. */ -+ if (abfd->archive_plugin_fd == -1) -+ { -+ close (fd); -+ return; -+ } -+ - abfd->archive_plugin_fd_open_count--; - /* Dup the archive plugin file descriptor for later use, which - will be closed by _bfd_archive_close_and_cleanup. */ ---- a/ld/testsuite/ld-plugin/lto.exp -+++ b/ld/testsuite/ld-plugin/lto.exp -@@ -687,6 +687,40 @@ if { [is_elf_format] && [check_lto_share - } - } - -+run_cc_link_tests [list \ -+ [list \ -+ "Build pr28138.a" \ -+ "-T" "" \ -+ {pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \ -+ pr28138-6.c pr28138-7.c} {} "pr28138.a" \ -+ ] \ -+ [list \ -+ "Build pr28138.o" \ -+ "" "" \ -+ {pr28138.c} {} \ -+ ] \ -+] -+ -+set exec_output [run_host_cmd "sh" \ -+ "-c \"ulimit -n 20; \ -+ $CC -Btmpdir/ld -o tmpdir/pr28138 \ -+ tmpdir/pr28138.o tmpdir/pr28138.a\""] -+set exec_output [prune_warnings $exec_output] -+if [string match "" $exec_output] then { -+ if { [isnative] } { -+ set exec_output [run_host_cmd "tmpdir/pr28138" ""] -+ if [string match "PASS" $exec_output] then { -+ pass "PR ld/28138" -+ } else { -+ fail "PR ld/28138" -+ } -+ } else { -+ pass "PR ld/28138" -+ } -+} else { -+ fail "PR ld/28138" -+} -+ - set testname "Build liblto-11.a" - remote_file host delete "tmpdir/liblto-11.a" - set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"] ---- /dev/null -+++ b/ld/testsuite/ld-plugin/pr28138-1.c -@@ -0,0 +1,6 @@ -+extern int a0(void); -+int -+a1(void) -+{ -+ return 1 + a0(); -+} ---- /dev/null -+++ b/ld/testsuite/ld-plugin/pr28138-2.c -@@ -0,0 +1,6 @@ -+extern int a1(void); -+int -+a2(void) -+{ -+ return 1 + a1(); -+} ---- /dev/null -+++ b/ld/testsuite/ld-plugin/pr28138-3.c -@@ -0,0 +1,6 @@ -+extern int a2(void); -+int -+a3(void) -+{ -+ return 1 + a2(); -+} ---- /dev/null -+++ b/ld/testsuite/ld-plugin/pr28138-4.c -@@ -0,0 +1,6 @@ -+extern int a3(void); -+int -+a4(void) -+{ -+ return 1 + a3(); -+} ---- /dev/null -+++ b/ld/testsuite/ld-plugin/pr28138-5.c -@@ -0,0 +1,6 @@ -+extern int a4(void); -+int -+a5(void) -+{ -+ return 1 + a4(); -+} ---- /dev/null -+++ b/ld/testsuite/ld-plugin/pr28138-6.c -@@ -0,0 +1,6 @@ -+extern int a5(void); -+int -+a6(void) -+{ -+ return 1 + a5(); -+} ---- /dev/null -+++ b/ld/testsuite/ld-plugin/pr28138-7.c -@@ -0,0 +1,6 @@ -+extern int a6(void); -+int -+a7(void) -+{ -+ return 1 + a6(); -+} ---- /dev/null -+++ b/ld/testsuite/ld-plugin/pr28138.c -@@ -0,0 +1,20 @@ -+#include -+ -+extern int a7(void); -+ -+int -+a0(void) -+{ -+ return 0; -+} -+ -+int -+main() -+{ -+ if (a7() == 7) -+ { -+ printf ("PASS\n"); -+ return 0; -+ } -+ return 1; -+} diff --git a/toolchain/binutils/patches/2.38/001-PR-30569-always-call-elf_backend_size_dynamic_sectio.patch b/toolchain/binutils/patches/2.38/001-PR-30569-always-call-elf_backend_size_dynamic_sectio.patch deleted file mode 100644 index 94488c3290..0000000000 --- a/toolchain/binutils/patches/2.38/001-PR-30569-always-call-elf_backend_size_dynamic_sectio.patch +++ /dev/null @@ -1,2172 +0,0 @@ -From af969b14aedcc0ae27dcefab4327ff2d153dec8b Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Thu, 28 Mar 2024 19:25:42 +1030 -Subject: [PATCH 1/2] PR 30569, always call elf_backend_size_dynamic_sections - -This largely mechanical patch is preparation for a followup patch. - -For quite some time I've thought that it would be useful to call -elf_backend_size_dynamic_sections even when no dynamic objects are -seen by the linker. That's what this patch does, with some renaming. -There are no functional changes to the linker, just a move of the -dynobj test in bfd_elf_size_dynamic_sections to target backend -functions, replacing the asserts/aborts already there. No doubt some -of the current always_size_sections functions could be moved to -size_dynamic_sections but I haven't made that change. - -Because both hooks are now always called, I have renamed -always_size_sections to early_size_sections and size_dynamic_sections -to late_size_sections. I condisdered calling late_size_sections plain -size_sections, since this is the usual target dynamic section sizing -hook, but decided that searching the sources for "size_sections" would -then hit early_size_sections and other functions. ---- - bfd/elf-bfd.h | 35 +++++++++++++++++------------------ - bfd/elf-m10300.c | 11 ++++++----- - bfd/elf32-arc.c | 9 +++++---- - bfd/elf32-arm.c | 15 ++++++++------- - bfd/elf32-bfin.c | 31 ++++++++++++++++--------------- - bfd/elf32-cr16.c | 11 ++++++----- - bfd/elf32-cris.c | 13 +++++++------ - bfd/elf32-csky.c | 8 ++++---- - bfd/elf32-frv.c | 23 ++++++++++++----------- - bfd/elf32-hppa.c | 8 ++++---- - bfd/elf32-i386.c | 7 +++---- - bfd/elf32-lm32.c | 15 ++++++++------- - bfd/elf32-m32c.c | 8 ++++---- - bfd/elf32-m32r.c | 11 ++++++----- - bfd/elf32-m68k.c | 16 ++++++++-------- - bfd/elf32-metag.c | 8 ++++---- - bfd/elf32-microblaze.c | 9 +++++---- - bfd/elf32-mips.c | 6 ++---- - bfd/elf32-nds32.c | 9 +++++---- - bfd/elf32-nios2.c | 15 ++++++++------- - bfd/elf32-or1k.c | 9 +++++---- - bfd/elf32-ppc.c | 11 ++++++----- - bfd/elf32-rl78.c | 8 ++++---- - bfd/elf32-s390.c | 10 +++++----- - bfd/elf32-score.c | 35 ++++++++++++++++++----------------- - bfd/elf32-score.h | 4 ++-- - bfd/elf32-score7.c | 13 +++++++------ - bfd/elf32-sh.c | 15 +++++++-------- - bfd/elf32-sparc.c | 3 +-- - bfd/elf32-tic6x.c | 14 +++++++------- - bfd/elf32-tilegx.c | 2 +- - bfd/elf32-tilepro.c | 11 +++++------ - bfd/elf32-vax.c | 16 +++++++--------- - bfd/elf32-xstormy16.c | 8 ++++---- - bfd/elf32-xtensa.c | 13 ++++++------- - bfd/elf64-alpha.c | 19 ++++++++++--------- - bfd/elf64-hppa.c | 11 ++++------- - bfd/elf64-ia64-vms.c | 13 +++++++------ - bfd/elf64-mips.c | 8 ++++---- - bfd/elf64-ppc.c | 12 ++++++------ - bfd/elf64-s390.c | 10 +++++----- - bfd/elf64-sparc.c | 4 ++-- - bfd/elf64-tilegx.c | 2 +- - bfd/elf64-x86-64.c | 7 +++---- - bfd/elflink.c | 9 ++++----- - bfd/elfn32-mips.c | 6 ++---- - bfd/elfnn-aarch64.c | 21 +++++++++++---------- - bfd/elfnn-ia64.c | 11 ++++++----- - bfd/elfnn-kvx.c | 19 +++++++++---------- - bfd/elfnn-loongarch.c | 9 +++++---- - bfd/elfnn-riscv.c | 7 ++++--- - bfd/elfxx-mips.c | 15 ++++++++------- - bfd/elfxx-mips.h | 4 ++-- - bfd/elfxx-sparc.c | 7 ++++--- - bfd/elfxx-sparc.h | 2 +- - bfd/elfxx-target.h | 12 ++++++------ - bfd/elfxx-tilegx.c | 7 ++++--- - bfd/elfxx-tilegx.h | 2 +- - bfd/elfxx-x86.c | 8 ++++---- - bfd/elfxx-x86.h | 8 ++++---- - ld/emultempl/vms.em | 7 +++---- - 61 files changed, 343 insertions(+), 337 deletions(-) - ---- a/bfd/elf-bfd.h -+++ b/bfd/elf-bfd.h -@@ -1135,7 +1135,7 @@ struct elf_backend_data - /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend - linker for every symbol which is defined by a dynamic object and - referenced by a regular object. This is called after all the -- input files have been seen, but before the SIZE_DYNAMIC_SECTIONS -+ input files have been seen, but before the LATE_SIZE_SECTIONS - function has been called. The hash table entry should be - bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be - defined in a section from a dynamic object. Dynamic object -@@ -1147,24 +1147,23 @@ struct elf_backend_data - bool (*elf_backend_adjust_dynamic_symbol) - (struct bfd_link_info *info, struct elf_link_hash_entry *h); - -- /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker -- after all the linker input files have been seen but before the -- section sizes have been set. This is called after -- ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS. */ -- bool (*elf_backend_always_size_sections) -+ /* The EARLY_SIZE_SECTIONS and LATE_SIZE_SECTIONS functions are -+ called by the backend linker after all linker input files have -+ been seen and sections have been assigned to output sections, but -+ before the section sizes have been set. Both of these functions -+ are called even when no dynamic object is seen by the linker. -+ Between them, they must set the sizes of the dynamic sections and -+ other backend specific sections, and may fill in their contents. -+ Most backends need only use LATE_SIZE_SECTIONS. -+ EARLY_SIZE_SECTIONS is called before --export-dynamic makes some -+ symbols dynamic and before ADJUST_DYNAMIC_SYMBOL processes -+ dynamic symbols, LATE_SIZE_SECTIONS afterwards. The generic ELF -+ linker can handle the .dynsym, .dynstr and .hash sections. -+ Besides those, these functions must handle the .interp section -+ and any other sections created by CREATE_DYNAMIC_SECTIONS. */ -+ bool (*elf_backend_early_size_sections) - (bfd *output_bfd, struct bfd_link_info *info); -- -- /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend -- linker after all the linker input files have been seen but before -- the sections sizes have been set. This is called after -- ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols. -- It is only called when linking against a dynamic object. It must -- set the sizes of the dynamic sections, and may fill in their -- contents as well. The generic ELF linker can handle the .dynsym, -- .dynstr and .hash sections. This function must handle the -- .interp section and any sections created by the -- CREATE_DYNAMIC_SECTIONS entry point. */ -- bool (*elf_backend_size_dynamic_sections) -+ bool (*elf_backend_late_size_sections) - (bfd *output_bfd, struct bfd_link_info *info); - - /* The STRIP_ZERO_SIZED_DYNAMIC_SECTIONS function is called by the ---- a/bfd/elf-m10300.c -+++ b/bfd/elf-m10300.c -@@ -5003,8 +5003,8 @@ _bfd_mn10300_elf_adjust_dynamic_symbol ( - /* Set the sizes of the dynamic sections. */ - - static bool --_bfd_mn10300_elf_size_dynamic_sections (bfd * output_bfd, -- struct bfd_link_info * info) -+_bfd_mn10300_elf_late_size_sections (bfd * output_bfd, -+ struct bfd_link_info * info) - { - struct elf32_mn10300_link_hash_table *htab = elf32_mn10300_hash_table (info); - bfd * dynobj; -@@ -5012,7 +5012,8 @@ _bfd_mn10300_elf_size_dynamic_sections ( - bool relocs; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5499,8 +5500,8 @@ mn10300_elf_mkobject (bfd *abfd) - _bfd_mn10300_elf_create_dynamic_sections - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mn10300_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- _bfd_mn10300_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_mn10300_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_symbol \ - _bfd_mn10300_elf_finish_dynamic_symbol ---- a/bfd/elf32-arc.c -+++ b/bfd/elf32-arc.c -@@ -2702,8 +2702,8 @@ elf_arc_finish_dynamic_sections (bfd * o - - /* Set the sizes of the dynamic sections. */ - static bool --elf_arc_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_arc_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -2711,7 +2711,8 @@ elf_arc_size_dynamic_sections (bfd *outp - struct elf_link_hash_table *htab = elf_hash_table (info); - - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->dynamic_sections_created) - { -@@ -3126,7 +3127,7 @@ arc_elf_relax_section (bfd *abfd, asecti - #define elf_backend_finish_dynamic_symbol elf_arc_finish_dynamic_symbol - - #define elf_backend_finish_dynamic_sections elf_arc_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf_arc_size_dynamic_sections -+#define elf_backend_late_size_sections elf_arc_late_size_sections - - #define elf_backend_can_gc_sections 1 - #define elf_backend_want_got_plt 1 ---- a/bfd/elf32-arm.c -+++ b/bfd/elf32-arm.c -@@ -16709,8 +16709,8 @@ bfd_elf32_arm_set_byteswap_code (struct - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info * info) -+elf32_arm_late_size_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info * info) - { - bfd * dynobj; - asection * s; -@@ -16723,7 +16723,9 @@ elf32_arm_size_dynamic_sections (bfd * o - return false; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; -+ - check_use_blx (htab); - - if (elf_hash_table (info)->dynamic_sections_created) -@@ -17095,8 +17097,7 @@ elf32_arm_size_dynamic_sections (bfd * o - _TLS_MODULE_BASE_, if needed. */ - - static bool --elf32_arm_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_arm_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - asection *tls_sec; - struct elf32_arm_link_hash_table *htab; -@@ -20263,8 +20264,8 @@ elf32_arm_backend_symbol_processing (bfd - #define elf_backend_create_dynamic_sections elf32_arm_create_dynamic_sections - #define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections --#define elf_backend_always_size_sections elf32_arm_always_size_sections -+#define elf_backend_late_size_sections elf32_arm_late_size_sections -+#define elf_backend_early_size_sections elf32_arm_early_size_sections - #define elf_backend_init_index_section _bfd_elf_init_2_index_sections - #define elf_backend_init_file_header elf32_arm_init_file_header - #define elf_backend_reloc_type_class elf32_arm_reloc_type_class ---- a/bfd/elf32-bfin.c -+++ b/bfd/elf32-bfin.c -@@ -4031,8 +4031,8 @@ _bfinfdpic_size_got_plt (bfd *output_bfd - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_bfinfdpic_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_bfinfdpic_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct elf_link_hash_table *htab; - bfd *dynobj; -@@ -4041,7 +4041,8 @@ elf32_bfinfdpic_size_dynamic_sections (b - - htab = elf_hash_table (info); - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->dynamic_sections_created) - { -@@ -4090,7 +4091,7 @@ elf32_bfinfdpic_size_dynamic_sections (b - } - - static bool --elf32_bfinfdpic_always_size_sections (bfd *output_bfd, -+elf32_bfinfdpic_early_size_sections (bfd *output_bfd, - struct bfd_link_info *info) - { - if (!bfd_link_relocatable (info) -@@ -5128,15 +5129,16 @@ bfin_discard_copies (struct elf_link_has - } - - static bool --bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+bfin_late_size_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5428,8 +5430,7 @@ struct bfd_elf_special_section const elf - #define elf_backend_check_relocs bfin_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - bfin_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- bfin_size_dynamic_sections -+#define elf_backend_late_size_sections bfin_late_size_sections - #define elf_backend_relocate_section bfin_relocate_section - #define elf_backend_finish_dynamic_symbol \ - bfin_finish_dynamic_symbol -@@ -5475,9 +5476,9 @@ struct bfd_elf_special_section const elf - #undef bfd_elf32_bfd_link_hash_table_create - #define bfd_elf32_bfd_link_hash_table_create \ - bfinfdpic_elf_link_hash_table_create --#undef elf_backend_always_size_sections --#define elf_backend_always_size_sections \ -- elf32_bfinfdpic_always_size_sections -+#undef elf_backend_early_size_sections -+#define elf_backend_early_size_sections \ -+ elf32_bfinfdpic_early_size_sections - - #undef elf_backend_create_dynamic_sections - #define elf_backend_create_dynamic_sections \ -@@ -5485,9 +5486,9 @@ struct bfd_elf_special_section const elf - #undef elf_backend_adjust_dynamic_symbol - #define elf_backend_adjust_dynamic_symbol \ - elf32_bfinfdpic_adjust_dynamic_symbol --#undef elf_backend_size_dynamic_sections --#define elf_backend_size_dynamic_sections \ -- elf32_bfinfdpic_size_dynamic_sections -+#undef elf_backend_late_size_sections -+#define elf_backend_late_size_sections \ -+ elf32_bfinfdpic_late_size_sections - #undef elf_backend_finish_dynamic_symbol - #define elf_backend_finish_dynamic_symbol \ - elf32_bfinfdpic_finish_dynamic_symbol ---- a/bfd/elf32-cr16.c -+++ b/bfd/elf32-cr16.c -@@ -2381,15 +2381,16 @@ _bfd_cr16_elf_adjust_dynamic_symbol (str - /* Set the sizes of the dynamic sections. */ - - static bool --_bfd_cr16_elf_size_dynamic_sections (bfd * output_bfd, -- struct bfd_link_info * info) -+_bfd_cr16_elf_late_size_sections (bfd * output_bfd, -+ struct bfd_link_info * info) - { - bfd * dynobj; - asection * s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -2826,8 +2827,8 @@ _bfd_cr16_elf_reloc_type_class (const st - _bfd_cr16_elf_create_dynamic_sections - #define elf_backend_adjust_dynamic_symbol \ - _bfd_cr16_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- _bfd_cr16_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_cr16_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_symbol \ - _bfd_cr16_elf_finish_dynamic_symbol ---- a/bfd/elf32-cris.c -+++ b/bfd/elf32-cris.c -@@ -2527,7 +2527,7 @@ cris_elf_plt_sym_val (bfd_vma i ATTRIBUT - entry but we found we will not create any. Called when we find we will - not have any PLT for this symbol, by for example - elf_cris_adjust_dynamic_symbol when we're doing a proper dynamic link, -- or elf_cris_size_dynamic_sections if no dynamic sections will be -+ or elf_cris_late_size_sections if no dynamic sections will be - created (we're only linking static objects). */ - - static bool -@@ -3508,8 +3508,8 @@ cris_elf_check_relocs (bfd *abfd, - /* Set the sizes of the dynamic sections. */ - - static bool --elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_cris_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_cris_link_hash_table * htab; - bfd *dynobj; -@@ -3521,7 +3521,8 @@ elf_cris_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -4090,8 +4091,8 @@ elf_cris_got_elt_size (bfd *abfd ATTRIBU - elf_cris_adjust_dynamic_symbol - #define elf_backend_copy_indirect_symbol \ - elf_cris_copy_indirect_symbol --#define elf_backend_size_dynamic_sections \ -- elf_cris_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elf_cris_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_finish_dynamic_symbol \ - elf_cris_finish_dynamic_symbol ---- a/bfd/elf32-csky.c -+++ b/bfd/elf32-csky.c -@@ -1893,8 +1893,8 @@ csky_allocate_dynrelocs (struct elf_link - /* Set the sizes of the dynamic sections. */ - - static bool --csky_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+csky_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct csky_elf_link_hash_table *htab; - bfd *dynobj; -@@ -1907,7 +1907,7 @@ csky_elf_size_dynamic_sections (bfd *out - return false; - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- return false; -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -5344,7 +5344,7 @@ elf32_csky_obj_attrs_handle_unknown (bfd - /* Dynamic relocate related API. */ - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_adjust_dynamic_symbol csky_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections csky_elf_size_dynamic_sections -+#define elf_backend_late_size_sections csky_elf_late_size_sections - #define elf_backend_finish_dynamic_symbol csky_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections csky_elf_finish_dynamic_sections - #define elf_backend_rela_normal 1 ---- a/bfd/elf32-frv.c -+++ b/bfd/elf32-frv.c -@@ -5423,15 +5423,16 @@ _frvfdpic_size_got_plt (bfd *output_bfd, - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_frvfdpic_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_frvfdpic_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - struct _frvfdpic_dynamic_got_plt_info gpinfo; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5472,8 +5473,8 @@ elf32_frvfdpic_size_dynamic_sections (bf - } - - static bool --elf32_frvfdpic_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_frvfdpic_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - if (!bfd_link_relocatable (info) - && !bfd_elf_stack_segment_size (output_bfd, info, -@@ -6817,9 +6818,9 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_In - #undef bfd_elf32_bfd_link_hash_table_create - #define bfd_elf32_bfd_link_hash_table_create \ - frvfdpic_elf_link_hash_table_create --#undef elf_backend_always_size_sections --#define elf_backend_always_size_sections \ -- elf32_frvfdpic_always_size_sections -+#undef elf_backend_early_size_sections -+#define elf_backend_early_size_sections \ -+ elf32_frvfdpic_early_size_sections - - #undef elf_backend_create_dynamic_sections - #define elf_backend_create_dynamic_sections \ -@@ -6827,9 +6828,9 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_In - #undef elf_backend_adjust_dynamic_symbol - #define elf_backend_adjust_dynamic_symbol \ - elf32_frvfdpic_adjust_dynamic_symbol --#undef elf_backend_size_dynamic_sections --#define elf_backend_size_dynamic_sections \ -- elf32_frvfdpic_size_dynamic_sections -+#undef elf_backend_late_size_sections -+#define elf_backend_late_size_sections \ -+ elf32_frvfdpic_late_size_sections - #undef bfd_elf32_bfd_relax_section - #define bfd_elf32_bfd_relax_section \ - elf32_frvfdpic_relax_section ---- a/bfd/elf32-hppa.c -+++ b/bfd/elf32-hppa.c -@@ -2042,8 +2042,8 @@ clobber_millicode_symbols (struct elf_li - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf32_hppa_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf32_hppa_link_hash_table *htab; - bfd *dynobj; -@@ -2057,7 +2057,7 @@ elf32_hppa_size_dynamic_sections (bfd *o - - dynobj = htab->etab.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->etab.dynamic_sections_created) - { -@@ -4450,7 +4450,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Inte - #define elf_backend_hide_symbol elf32_hppa_hide_symbol - #define elf_backend_finish_dynamic_symbol elf32_hppa_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections elf32_hppa_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf32_hppa_size_dynamic_sections -+#define elf_backend_late_size_sections elf32_hppa_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_gc_mark_hook elf32_hppa_gc_mark_hook - #define elf_backend_grok_prstatus elf32_hppa_grok_prstatus ---- a/bfd/elf32-i386.c -+++ b/bfd/elf32-i386.c -@@ -1905,8 +1905,7 @@ elf_i386_scan_relocs (bfd *abfd, - } - - static bool --elf_i386_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf_i386_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *abfd; - -@@ -1919,7 +1918,7 @@ elf_i386_always_size_sections (bfd *outp - elf_i386_scan_relocs)) - return false; - -- return _bfd_x86_elf_always_size_sections (output_bfd, info); -+ return _bfd_x86_elf_early_size_sections (output_bfd, info); - } - - /* Set the correct type for an x86 ELF section. We do this by the -@@ -4412,7 +4411,7 @@ elf_i386_link_setup_gnu_properties (stru - #define bfd_elf32_get_synthetic_symtab elf_i386_get_synthetic_symtab - - #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible --#define elf_backend_always_size_sections elf_i386_always_size_sections -+#define elf_backend_early_size_sections elf_i386_early_size_sections - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_fake_sections elf_i386_fake_sections - #define elf_backend_finish_dynamic_sections elf_i386_finish_dynamic_sections ---- a/bfd/elf32-lm32.c -+++ b/bfd/elf32-lm32.c -@@ -1906,8 +1906,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --lm32_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+lm32_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct elf_lm32_link_hash_table *htab; - bfd *dynobj; -@@ -1920,7 +1920,8 @@ lm32_elf_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -2309,7 +2310,7 @@ lm32_elf_create_dynamic_sections (bfd *a - } - - static bool --lm32_elf_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+lm32_elf_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - if (!bfd_link_relocatable (info)) - { -@@ -2395,7 +2396,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bf - #define bfd_elf32_bfd_link_hash_table_create lm32_elf_link_hash_table_create - #define elf_backend_check_relocs lm32_elf_check_relocs - #define elf_backend_reloc_type_class lm32_elf_reloc_type_class --#define elf_backend_size_dynamic_sections lm32_elf_size_dynamic_sections -+#define elf_backend_late_size_sections lm32_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_create_dynamic_sections lm32_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections lm32_elf_finish_dynamic_sections -@@ -2416,8 +2417,8 @@ lm32_elf_fdpic_copy_private_bfd_data (bf - #undef elf32_bed - #define elf32_bed elf32_lm32fdpic_bed - --#undef elf_backend_always_size_sections --#define elf_backend_always_size_sections lm32_elf_always_size_sections -+#undef elf_backend_early_size_sections -+#define elf_backend_early_size_sections lm32_elf_early_size_sections - #undef bfd_elf32_bfd_copy_private_bfd_data - #define bfd_elf32_bfd_copy_private_bfd_data lm32_elf_fdpic_copy_private_bfd_data - ---- a/bfd/elf32-m32c.c -+++ b/bfd/elf32-m32c.c -@@ -773,8 +773,8 @@ m32c_elf_finish_dynamic_sections (bfd *a - } - - static bool --m32c_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+m32c_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *splt; -@@ -2131,8 +2131,8 @@ _bfd_m32c_elf_eh_frame_address_size (bfd - #define elf_backend_check_relocs m32c_elf_check_relocs - #define elf_backend_object_p m32c_elf_object_p - #define elf_symbol_leading_char ('_') --#define elf_backend_always_size_sections \ -- m32c_elf_always_size_sections -+#define elf_backend_early_size_sections \ -+ m32c_elf_early_size_sections - #define elf_backend_finish_dynamic_sections \ - m32c_elf_finish_dynamic_sections - ---- a/bfd/elf32-m32r.c -+++ b/bfd/elf32-m32r.c -@@ -1958,8 +1958,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+m32r_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_link_hash_table *htab; - bfd *dynobj; -@@ -1968,7 +1968,7 @@ m32r_elf_size_dynamic_sections (bfd *out - bfd *ibfd; - - #ifdef DEBUG_PIC -- printf ("m32r_elf_size_dynamic_sections()\n"); -+ printf ("m32r_elf_late_size_sections()\n"); - #endif - - htab = m32r_elf_hash_table (info); -@@ -1976,7 +1976,8 @@ m32r_elf_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->dynamic_sections_created) - { -@@ -3658,7 +3659,7 @@ m32r_elf_reloc_type_class (const struct - - #define elf_backend_create_dynamic_sections m32r_elf_create_dynamic_sections - #define bfd_elf32_bfd_link_hash_table_create m32r_elf_link_hash_table_create --#define elf_backend_size_dynamic_sections m32r_elf_size_dynamic_sections -+#define elf_backend_late_size_sections m32r_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_sections m32r_elf_finish_dynamic_sections - #define elf_backend_adjust_dynamic_symbol m32r_elf_adjust_dynamic_symbol ---- a/bfd/elf32-m68k.c -+++ b/bfd/elf32-m68k.c -@@ -2934,7 +2934,7 @@ elf_m68k_get_plt_info (bfd *output_bfd) - It's a convenient place to determine the PLT style. */ - - static bool --elf_m68k_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf_m68k_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - /* Bind input BFDs to GOTs and calculate sizes of .got and .rela.got - sections. */ -@@ -3107,15 +3107,16 @@ elf_m68k_adjust_dynamic_symbol (struct b - /* Set the sizes of the dynamic sections. */ - - static bool --elf_m68k_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_m68k_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -4628,12 +4629,11 @@ elf_m68k_grok_psinfo (bfd *abfd, Elf_Int - #define bfd_elf32_bfd_final_link bfd_elf_final_link - - #define elf_backend_check_relocs elf_m68k_check_relocs --#define elf_backend_always_size_sections \ -- elf_m68k_always_size_sections -+#define elf_backend_early_size_sections \ -+ elf_m68k_early_size_sections - #define elf_backend_adjust_dynamic_symbol \ - elf_m68k_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- elf_m68k_size_dynamic_sections -+#define elf_backend_late_size_sections elf_m68k_late_size_sections - #define elf_backend_final_write_processing elf_m68k_final_write_processing - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section elf_m68k_relocate_section ---- a/bfd/elf32-metag.c -+++ b/bfd/elf32-metag.c -@@ -2717,8 +2717,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_metag_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_metag_link_hash_table *htab; - bfd *dynobj; -@@ -2729,7 +2729,7 @@ elf_metag_size_dynamic_sections (bfd *ou - htab = metag_link_hash_table (info); - dynobj = htab->etab.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->etab.dynamic_sections_created) - { -@@ -4019,7 +4019,7 @@ elf_metag_plt_sym_val (bfd_vma i, const - #define elf_backend_adjust_dynamic_symbol elf_metag_adjust_dynamic_symbol - #define elf_backend_finish_dynamic_symbol elf_metag_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections elf_metag_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf_metag_size_dynamic_sections -+#define elf_backend_late_size_sections elf_metag_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_init_file_header elf_metag_init_file_header ---- a/bfd/elf32-microblaze.c -+++ b/bfd/elf32-microblaze.c -@@ -2901,8 +2901,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+microblaze_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf32_mb_link_hash_table *htab; - bfd *dynobj; -@@ -2914,7 +2914,8 @@ microblaze_elf_size_dynamic_sections (bf - return false; - - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - /* Set up .got offsets for local syms, and space for local dynamic - relocs. */ -@@ -3431,7 +3432,7 @@ microblaze_elf_add_symbol_hook (bfd *abf - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections microblaze_elf_finish_dynamic_sections - #define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol --#define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections -+#define elf_backend_late_size_sections microblaze_elf_late_size_sections - #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook - - #include "elf32-target.h" ---- a/bfd/elf32-mips.c -+++ b/bfd/elf32-mips.c -@@ -2526,10 +2526,8 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_mips_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_mips_elf_size_dynamic_sections -+#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections -+#define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf32-nds32.c -+++ b/bfd/elf32-nds32.c -@@ -4248,8 +4248,8 @@ elf32_nds32_add_dynreloc (bfd *output_bf - /* Set the sizes of the dynamic sections. */ - - static bool --nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+nds32_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_nds32_link_hash_table *htab; - bfd *dynobj; -@@ -4262,7 +4262,8 @@ nds32_elf_size_dynamic_sections (bfd *ou - return false; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -13930,7 +13931,7 @@ nds32_elf_unify_tls_model (bfd *inbfd, a - #define elf_backend_create_dynamic_sections nds32_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections nds32_elf_finish_dynamic_sections - #define elf_backend_finish_dynamic_symbol nds32_elf_finish_dynamic_symbol --#define elf_backend_size_dynamic_sections nds32_elf_size_dynamic_sections -+#define elf_backend_late_size_sections nds32_elf_late_size_sections - #define elf_backend_relocate_section nds32_elf_relocate_section - #define elf_backend_gc_mark_hook nds32_elf_gc_mark_hook - #define elf_backend_grok_prstatus nds32_elf_grok_prstatus ---- a/bfd/elf32-nios2.c -+++ b/bfd/elf32-nios2.c -@@ -5411,7 +5411,7 @@ nios2_elf32_adjust_dynamic_symbol (struc - return true; - } - --/* Worker function for nios2_elf32_size_dynamic_sections. */ -+/* Worker function for nios2_elf32_late_size_sections. */ - static bool - adjust_dynrelocs (struct elf_link_hash_entry *h, PTR inf) - { -@@ -5438,7 +5438,7 @@ adjust_dynrelocs (struct elf_link_hash_e - return true; - } - --/* Another worker function for nios2_elf32_size_dynamic_sections. -+/* Another worker function for nios2_elf32_late_size_sections. - Allocate space in .plt, .got and associated reloc sections for - dynamic relocs. */ - static bool -@@ -5673,11 +5673,11 @@ allocate_dynrelocs (struct elf_link_hash - return true; - } - --/* Implement elf_backend_size_dynamic_sections: -+/* Implement elf_backend_late_size_sections: - Set the sizes of the dynamic sections. */ - static bool --nios2_elf32_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+nios2_elf32_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -5687,7 +5687,8 @@ nios2_elf32_size_dynamic_sections (bfd * - - htab = elf32_nios2_hash_table (info); - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - htab->res_n_size = 0; - if (htab->root.dynamic_sections_created) -@@ -6058,7 +6059,7 @@ const struct bfd_elf_special_section elf - nios2_elf32_finish_dynamic_sections - #define elf_backend_adjust_dynamic_symbol nios2_elf32_adjust_dynamic_symbol - #define elf_backend_reloc_type_class nios2_elf32_reloc_type_class --#define elf_backend_size_dynamic_sections nios2_elf32_size_dynamic_sections -+#define elf_backend_late_size_sections nios2_elf32_late_size_sections - #define elf_backend_add_symbol_hook nios2_elf_add_symbol_hook - #define elf_backend_copy_indirect_symbol nios2_elf32_copy_indirect_symbol - #define elf_backend_object_p nios2_elf32_object_p ---- a/bfd/elf32-or1k.c -+++ b/bfd/elf32-or1k.c -@@ -3023,8 +3023,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+or1k_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_or1k_link_hash_table *htab; - bfd *dynobj; -@@ -3037,7 +3037,8 @@ or1k_elf_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -3390,7 +3391,7 @@ or1k_grok_psinfo (bfd *abfd, Elf_Interna - #define elf_backend_copy_indirect_symbol or1k_elf_copy_indirect_symbol - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections or1k_elf_finish_dynamic_sections --#define elf_backend_size_dynamic_sections or1k_elf_size_dynamic_sections -+#define elf_backend_late_size_sections or1k_elf_late_size_sections - #define elf_backend_adjust_dynamic_symbol or1k_elf_adjust_dynamic_symbol - #define elf_backend_finish_dynamic_symbol or1k_elf_finish_dynamic_symbol - ---- a/bfd/elf32-ppc.c -+++ b/bfd/elf32-ppc.c -@@ -5497,8 +5497,8 @@ static const unsigned char glink_eh_fram - /* Set the sizes of the dynamic sections. */ - - static bool --ppc_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+ppc_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct ppc_elf_link_hash_table *htab; - asection *s; -@@ -5506,11 +5506,12 @@ ppc_elf_size_dynamic_sections (bfd *outp - bfd *ibfd; - - #ifdef DEBUG -- fprintf (stderr, "ppc_elf_size_dynamic_sections called\n"); -+ fprintf (stderr, "ppc_elf_late_size_sections called\n"); - #endif - - htab = ppc_elf_hash_table (info); -- BFD_ASSERT (htab->elf.dynobj != NULL); -+ if (htab->elf.dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -10410,7 +10411,7 @@ ppc_elf_finish_dynamic_sections (bfd *ou - #define elf_backend_copy_indirect_symbol ppc_elf_copy_indirect_symbol - #define elf_backend_adjust_dynamic_symbol ppc_elf_adjust_dynamic_symbol - #define elf_backend_add_symbol_hook ppc_elf_add_symbol_hook --#define elf_backend_size_dynamic_sections ppc_elf_size_dynamic_sections -+#define elf_backend_late_size_sections ppc_elf_late_size_sections - #define elf_backend_hash_symbol ppc_elf_hash_symbol - #define elf_backend_finish_dynamic_symbol ppc_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections ppc_elf_finish_dynamic_sections ---- a/bfd/elf32-rl78.c -+++ b/bfd/elf32-rl78.c -@@ -1440,8 +1440,8 @@ rl78_elf_finish_dynamic_sections (bfd *a - } - - static bool --rl78_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+rl78_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *splt; -@@ -2609,8 +2609,8 @@ rl78_elf_relax_section (bfd *abfd, - - #define bfd_elf32_bfd_relax_section rl78_elf_relax_section - #define elf_backend_check_relocs rl78_elf_check_relocs --#define elf_backend_always_size_sections \ -- rl78_elf_always_size_sections -+#define elf_backend_early_size_sections \ -+ rl78_elf_early_size_sections - #define elf_backend_finish_dynamic_sections \ - rl78_elf_finish_dynamic_sections - ---- a/bfd/elf32-s390.c -+++ b/bfd/elf32-s390.c -@@ -1366,7 +1366,7 @@ elf_s390_gc_mark_hook (asection *sec, - entry but we found we will not create any. Called when we find we will - not have any PLT for this symbol, by for example - elf_s390_adjust_dynamic_symbol when we're doing a proper dynamic link, -- or elf_s390_size_dynamic_sections if no dynamic sections will be -+ or elf_s390_late_size_sections if no dynamic sections will be - created (we're only linking static objects). */ - - static void -@@ -1778,8 +1778,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_s390_link_hash_table *htab; - bfd *dynobj; -@@ -1790,7 +1790,7 @@ elf_s390_size_dynamic_sections (bfd *out - htab = elf_s390_hash_table (info); - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -3926,7 +3926,7 @@ elf32_s390_merge_private_bfd_data (bfd * - #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook - #define elf_backend_reloc_type_class elf_s390_reloc_type_class - #define elf_backend_relocate_section elf_s390_relocate_section --#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections -+#define elf_backend_late_size_sections elf_s390_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_grok_prstatus elf_s390_grok_prstatus - #define elf_backend_grok_psinfo elf_s390_grok_psinfo ---- a/bfd/elf32-score.c -+++ b/bfd/elf32-score.c -@@ -1089,7 +1089,7 @@ score_elf_got_info (bfd *abfd, asection - appear towards the end. This reduces the amount of GOT space - required. MAX_LOCAL is used to set the number of local symbols - known to be in the dynamic symbol table. During -- s3_bfd_score_elf_size_dynamic_sections, this value is 1. Afterward, the -+ s3_bfd_score_elf_late_size_sections, this value is 1. Afterward, the - section symbols are added and the count is higher. */ - static bool - score_elf_sort_hash_table (struct bfd_link_info *info, -@@ -3160,8 +3160,8 @@ s3_bfd_score_elf_adjust_dynamic_symbol ( - /* This function is called after all the input files have been read, - and the input sections have been assigned to output sections. */ - static bool --s3_bfd_score_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+s3_bfd_score_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -3237,14 +3237,15 @@ s3_bfd_score_elf_always_size_sections (b - - /* Set the sizes of the dynamic sections. */ - static bool --s3_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+s3_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool reltext; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -3313,7 +3314,7 @@ s3_bfd_score_elf_size_dynamic_sections ( - } - else if (startswith (name, ".got")) - { -- /* s3_bfd_score_elf_always_size_sections() has already done -+ /* s3_bfd_score_elf_early_size_sections() has already done - most of the work, but some symbols may have been mapped - to versions that we must now resolve in the got_entries - hash tables. */ -@@ -4177,22 +4178,22 @@ _bfd_score_elf_adjust_dynamic_symbol (st - } - - static bool --_bfd_score_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_score_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - if (bfd_get_mach (output_bfd) == bfd_mach_score3) -- return s3_bfd_score_elf_always_size_sections (output_bfd, info); -+ return s3_bfd_score_elf_early_size_sections (output_bfd, info); - else -- return s7_bfd_score_elf_always_size_sections (output_bfd, info); -+ return s7_bfd_score_elf_early_size_sections (output_bfd, info); - } - - static bool --_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - if (bfd_get_mach (output_bfd) == bfd_mach_score3) -- return s3_bfd_score_elf_size_dynamic_sections (output_bfd, info); -+ return s3_bfd_score_elf_late_size_sections (output_bfd, info); - else -- return s7_bfd_score_elf_size_dynamic_sections (output_bfd, info); -+ return s7_bfd_score_elf_late_size_sections (output_bfd, info); - } - - static bool -@@ -4455,10 +4456,10 @@ _bfd_score_elf_common_definition (Elf_In - _bfd_score_elf_section_from_bfd_section - #define elf_backend_adjust_dynamic_symbol \ - _bfd_score_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_score_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_score_elf_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ _bfd_score_elf_early_size_sections -+#define elf_backend_late_size_sections \ -+ _bfd_score_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_create_dynamic_sections \ - _bfd_score_elf_create_dynamic_sections ---- a/bfd/elf32-score.h -+++ b/bfd/elf32-score.h -@@ -78,10 +78,10 @@ s7_bfd_score_elf_adjust_dynamic_symbol ( - struct elf_link_hash_entry *); - - extern bool --s7_bfd_score_elf_always_size_sections (bfd *, struct bfd_link_info *); -+s7_bfd_score_elf_early_size_sections (bfd *, struct bfd_link_info *); - - extern bool --s7_bfd_score_elf_size_dynamic_sections (bfd *, struct bfd_link_info *); -+s7_bfd_score_elf_late_size_sections (bfd *, struct bfd_link_info *); - - extern bool - s7_bfd_score_elf_create_dynamic_sections (bfd *, struct bfd_link_info *); ---- a/bfd/elf32-score7.c -+++ b/bfd/elf32-score7.c -@@ -975,7 +975,7 @@ score_elf_got_info (bfd *abfd, asection - appear towards the end. This reduces the amount of GOT space - required. MAX_LOCAL is used to set the number of local symbols - known to be in the dynamic symbol table. During -- s7_bfd_score_elf_size_dynamic_sections, this value is 1. Afterward, the -+ s7_bfd_score_elf_late_size_sections, this value is 1. Afterward, the - section symbols are added and the count is higher. */ - - static bool -@@ -2969,8 +2969,8 @@ s7_bfd_score_elf_adjust_dynamic_symbol ( - and the input sections have been assigned to output sections. */ - - bool --s7_bfd_score_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+s7_bfd_score_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -3047,14 +3047,15 @@ s7_bfd_score_elf_always_size_sections (b - /* Set the sizes of the dynamic sections. */ - - bool --s7_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+s7_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool reltext; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -3123,7 +3124,7 @@ s7_bfd_score_elf_size_dynamic_sections ( - } - else if (startswith (name, ".got")) - { -- /* s7_bfd_score_elf_always_size_sections() has already done -+ /* s7_bfd_score_elf_early_size_sections() has already done - most of the work, but some symbols may have been mapped - to versions that we must now resolve in the got_entries - hash tables. */ ---- a/bfd/elf32-sh.c -+++ b/bfd/elf32-sh.c -@@ -2925,7 +2925,7 @@ allocate_dynrelocs (struct elf_link_hash - It's a convenient place to determine the PLT style. */ - - static bool --sh_elf_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+sh_elf_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - sh_elf_hash_table (info)->plt_info = get_plt_info (output_bfd, - bfd_link_pic (info)); -@@ -2940,8 +2940,8 @@ sh_elf_always_size_sections (bfd *output - /* Set the sizes of the dynamic sections. */ - - static bool --sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+sh_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_sh_link_hash_table *htab; - bfd *dynobj; -@@ -2954,7 +2954,8 @@ sh_elf_size_dynamic_sections (bfd *outpu - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -6589,10 +6590,8 @@ sh_elf_encode_eh_address (bfd *abfd, - sh_elf_link_hash_table_create - #define elf_backend_adjust_dynamic_symbol \ - sh_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- sh_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- sh_elf_size_dynamic_sections -+#define elf_backend_early_size_sections sh_elf_early_size_sections -+#define elf_backend_late_size_sections sh_elf_late_size_sections - #define elf_backend_omit_section_dynsym sh_elf_omit_section_dynsym - #define elf_backend_finish_dynamic_symbol \ - sh_elf_finish_dynamic_symbol ---- a/bfd/elf32-sparc.c -+++ b/bfd/elf32-sparc.c -@@ -248,8 +248,7 @@ elf32_sparc_reloc_type_class (const stru - #define elf_backend_adjust_dynamic_symbol \ - _bfd_sparc_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym _bfd_sparc_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections \ -- _bfd_sparc_elf_size_dynamic_sections -+#define elf_backend_late_size_sections _bfd_sparc_elf_late_size_sections - #define elf_backend_relocate_section _bfd_sparc_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ - _bfd_sparc_elf_finish_dynamic_symbol ---- a/bfd/elf32-tic6x.c -+++ b/bfd/elf32-tic6x.c -@@ -3160,7 +3160,7 @@ elf32_tic6x_allocate_dynrelocs (struct e - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_tic6x_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf32_tic6x_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct elf32_tic6x_link_hash_table *htab; - bfd *dynobj; -@@ -3171,7 +3171,7 @@ elf32_tic6x_size_dynamic_sections (bfd * - htab = elf32_tic6x_hash_table (info); - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -3358,7 +3358,7 @@ elf32_tic6x_size_dynamic_sections (bfd * - and the input sections have been assigned to output sections. */ - - static bool --elf32_tic6x_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf32_tic6x_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - if (elf32_tic6x_using_dsbt (output_bfd) && !bfd_link_relocatable (info) - && !bfd_elf_stack_segment_size (output_bfd, info, -@@ -4261,10 +4261,10 @@ elf32_tic6x_write_section (bfd *output_b - #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible - #define elf_backend_finish_dynamic_symbol \ - elf32_tic6x_finish_dynamic_symbol --#define elf_backend_always_size_sections \ -- elf32_tic6x_always_size_sections --#define elf_backend_size_dynamic_sections \ -- elf32_tic6x_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ elf32_tic6x_early_size_sections -+#define elf_backend_late_size_sections \ -+ elf32_tic6x_late_size_sections - #define elf_backend_finish_dynamic_sections \ - elf32_tic6x_finish_dynamic_sections - #define bfd_elf32_bfd_final_link \ ---- a/bfd/elf32-tilegx.c -+++ b/bfd/elf32-tilegx.c -@@ -105,7 +105,7 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_I - #define elf_backend_check_relocs tilegx_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol tilegx_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym tilegx_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections tilegx_elf_size_dynamic_sections -+#define elf_backend_late_size_sections tilegx_elf_late_size_sections - #define elf_backend_relocate_section tilegx_elf_relocate_section - #define elf_backend_finish_dynamic_symbol tilegx_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections tilegx_elf_finish_dynamic_sections ---- a/bfd/elf32-tilepro.c -+++ b/bfd/elf32-tilepro.c -@@ -2182,11 +2182,9 @@ tilepro_elf_omit_section_dynsym (bfd *ou - #define ELF32_DYNAMIC_INTERPRETER "/lib/ld.so.1" - - static bool --tilepro_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+tilepro_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { -- (void)output_bfd; -- - struct elf_link_hash_table *htab; - bfd *dynobj; - asection *s; -@@ -2195,7 +2193,8 @@ tilepro_elf_size_dynamic_sections (bfd * - htab = tilepro_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -3739,7 +3738,7 @@ tilepro_additional_program_headers (bfd - #define elf_backend_check_relocs tilepro_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol tilepro_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym tilepro_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections tilepro_elf_size_dynamic_sections -+#define elf_backend_late_size_sections tilepro_elf_late_size_sections - #define elf_backend_relocate_section tilepro_elf_relocate_section - #define elf_backend_finish_dynamic_symbol tilepro_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections tilepro_elf_finish_dynamic_sections ---- a/bfd/elf32-vax.c -+++ b/bfd/elf32-vax.c -@@ -36,7 +36,6 @@ static bool elf_vax_check_relocs (bfd *, - asection *, const Elf_Internal_Rela *); - static bool elf_vax_adjust_dynamic_symbol (struct bfd_link_info *, - struct elf_link_hash_entry *); --static bool elf_vax_size_dynamic_sections (bfd *, struct bfd_link_info *); - static int elf_vax_relocate_section (bfd *, struct bfd_link_info *, - bfd *, asection *, bfd_byte *, - Elf_Internal_Rela *, -@@ -985,8 +984,8 @@ elf_vax_discard_got_entries (struct elf_ - /* Discard unused dynamic data if this is a static link. */ - - static bool --elf_vax_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_vax_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -1024,14 +1023,15 @@ elf_vax_always_size_sections (bfd *outpu - /* Set the sizes of the dynamic sections. */ - - static bool --elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf_vax_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -1861,10 +1861,8 @@ elf_vax_plt_sym_val (bfd_vma i, const as - #define elf_backend_check_relocs elf_vax_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - elf_vax_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- elf_vax_always_size_sections --#define elf_backend_size_dynamic_sections \ -- elf_vax_size_dynamic_sections -+#define elf_backend_early_size_sections elf_vax_early_size_sections -+#define elf_backend_late_size_sections elf_vax_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section elf_vax_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf32-xstormy16.c -+++ b/bfd/elf32-xstormy16.c -@@ -706,8 +706,8 @@ xstormy16_elf_relax_section (bfd *dynobj - } - - static bool --xstormy16_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+xstormy16_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *splt; -@@ -1013,8 +1013,8 @@ xstormy16_elf_gc_mark_hook (asection *se - #define elf_backend_relocate_section xstormy16_elf_relocate_section - #define elf_backend_gc_mark_hook xstormy16_elf_gc_mark_hook - #define elf_backend_check_relocs xstormy16_elf_check_relocs --#define elf_backend_always_size_sections \ -- xstormy16_elf_always_size_sections -+#define elf_backend_early_size_sections \ -+ xstormy16_elf_early_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_sections \ ---- a/bfd/elf32-xtensa.c -+++ b/bfd/elf32-xtensa.c -@@ -1568,8 +1568,8 @@ elf_xtensa_allocate_local_got_size (stru - /* Set the sizes of the dynamic sections. */ - - static bool --elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_xtensa_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_xtensa_link_hash_table *htab; - bfd *dynobj, *abfd; -@@ -1586,7 +1586,7 @@ elf_xtensa_size_dynamic_sections (bfd *o - - dynobj = elf_hash_table (info)->dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - srelgot = htab->elf.srelgot; - srelplt = htab->elf.srelplt; - -@@ -1791,8 +1791,7 @@ elf_xtensa_size_dynamic_sections (bfd *o - } - - static bool --elf_xtensa_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf_xtensa_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct elf_xtensa_link_hash_table *htab; - asection *tls_sec; -@@ -11551,8 +11550,8 @@ static const struct bfd_elf_special_sect - #define elf_backend_object_p elf_xtensa_object_p - #define elf_backend_reloc_type_class elf_xtensa_reloc_type_class - #define elf_backend_relocate_section elf_xtensa_relocate_section --#define elf_backend_size_dynamic_sections elf_xtensa_size_dynamic_sections --#define elf_backend_always_size_sections elf_xtensa_always_size_sections -+#define elf_backend_late_size_sections elf_xtensa_late_size_sections -+#define elf_backend_early_size_sections elf_xtensa_early_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_special_sections elf_xtensa_special_sections - #define elf_backend_action_discarded elf_xtensa_action_discarded ---- a/bfd/elf64-alpha.c -+++ b/bfd/elf64-alpha.c -@@ -2579,8 +2579,8 @@ elf64_alpha_size_plt_section (struct bfd - } - - static bool --elf64_alpha_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf64_alpha_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *i; - struct alpha_elf_link_hash_table * htab; -@@ -2806,8 +2806,8 @@ elf64_alpha_size_rela_got_section (struc - /* Set the sizes of the dynamic sections. */ - - static bool --elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf64_alpha_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -2819,7 +2819,8 @@ elf64_alpha_size_dynamic_sections (bfd * - return false; - - dynobj = elf_hash_table(info)->dynobj; -- BFD_ASSERT(dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5465,10 +5466,10 @@ static const struct elf_size_info alpha_ - elf64_alpha_merge_symbol_attribute - #define elf_backend_copy_indirect_symbol \ - elf64_alpha_copy_indirect_symbol --#define elf_backend_always_size_sections \ -- elf64_alpha_always_size_sections --#define elf_backend_size_dynamic_sections \ -- elf64_alpha_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ elf64_alpha_early_size_sections -+#define elf_backend_late_size_sections \ -+ elf64_alpha_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_relocate_section \ ---- a/bfd/elf64-hppa.c -+++ b/bfd/elf64-hppa.c -@@ -176,9 +176,6 @@ static bool elf64_hppa_adjust_dynamic_sy - static bool elf64_hppa_mark_milli_and_exported_functions - (struct elf_link_hash_entry *, void *); - --static bool elf64_hppa_size_dynamic_sections -- (bfd *, struct bfd_link_info *); -- - static int elf64_hppa_link_output_symbol_hook - (struct bfd_link_info *, const char *, Elf_Internal_Sym *, - asection *, struct elf_link_hash_entry *); -@@ -1520,7 +1517,7 @@ elf64_hppa_mark_milli_and_exported_funct - the contents of our special sections. */ - - static bool --elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf64_hppa_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct elf64_hppa_link_hash_table *hppa_info; - struct elf64_hppa_allocate_data data; -@@ -1534,7 +1531,8 @@ elf64_hppa_size_dynamic_sections (bfd *o - return false; - - dynobj = hppa_info->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - /* Mark each function this program exports so that we will allocate - space in the .opd section for each function's FPTR. If we are -@@ -3984,8 +3982,7 @@ const struct elf_size_info hppa64_elf_si - #define elf_backend_adjust_dynamic_symbol \ - elf64_hppa_adjust_dynamic_symbol - --#define elf_backend_size_dynamic_sections \ -- elf64_hppa_size_dynamic_sections -+#define elf_backend_late_size_sections elf64_hppa_late_size_sections - - #define elf_backend_finish_dynamic_symbol \ - elf64_hppa_finish_dynamic_symbol ---- a/bfd/elf64-ia64-vms.c -+++ b/bfd/elf64-ia64-vms.c -@@ -2590,8 +2590,8 @@ elf64_ia64_adjust_dynamic_symbol (struct - } - - static bool --elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf64_ia64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf64_ia64_allocate_data data; - struct elf64_ia64_link_hash_table *ia64_info; -@@ -2600,11 +2600,12 @@ elf64_ia64_size_dynamic_sections (bfd *o - struct elf_link_hash_table *hash_table; - - hash_table = elf_hash_table (info); -- dynobj = hash_table->dynobj; - ia64_info = elf64_ia64_hash_table (info); - if (ia64_info == NULL) - return false; -- BFD_ASSERT(dynobj != NULL); -+ dynobj = hash_table->dynobj; -+ if (dynobj == NULL) -+ return true; - data.info = info; - - /* Allocate the GOT entries. */ -@@ -5484,8 +5485,8 @@ static const struct elf_size_info elf64_ - elf64_ia64_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - elf64_ia64_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- elf64_ia64_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elf64_ia64_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_relocate_section \ ---- a/bfd/elf64-mips.c -+++ b/bfd/elf64-mips.c -@@ -4741,10 +4741,10 @@ const struct elf_size_info mips_elf64_si - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_mips_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_mips_elf_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ _bfd_mips_elf_early_size_sections -+#define elf_backend_late_size_sections \ -+ _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf64-ppc.c -+++ b/bfd/elf64-ppc.c -@@ -119,8 +119,8 @@ static bfd_vma opd_entry_value - #define elf_backend_adjust_dynamic_symbol ppc64_elf_adjust_dynamic_symbol - #define elf_backend_hide_symbol ppc64_elf_hide_symbol - #define elf_backend_maybe_function_sym ppc64_elf_maybe_function_sym --#define elf_backend_always_size_sections ppc64_elf_edit --#define elf_backend_size_dynamic_sections ppc64_elf_size_dynamic_sections -+#define elf_backend_early_size_sections ppc64_elf_edit -+#define elf_backend_late_size_sections ppc64_elf_late_size_sections - #define elf_backend_hash_symbol ppc64_elf_hash_symbol - #define elf_backend_init_index_section _bfd_elf_init_2_index_sections - #define elf_backend_action_discarded ppc64_elf_action_discarded -@@ -10121,7 +10121,7 @@ allocate_dynrelocs (struct elf_link_hash - ((((v) & 0x3ffff0000ULL) << 16) | (v & 0xffff)) - #define HA34(v) ((v + (1ULL << 33)) >> 34) - --/* Called via elf_link_hash_traverse from ppc64_elf_size_dynamic_sections -+/* Called via elf_link_hash_traverse from ppc64_elf_late_size_sections - to set up space for global entry stubs. These are put in glink, - after the branch table. */ - -@@ -10198,8 +10198,8 @@ size_global_entry_stubs (struct elf_link - /* Set the sizes of the dynamic sections. */ - - static bool --ppc64_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+ppc64_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct ppc_link_hash_table *htab; - bfd *dynobj; -@@ -10214,7 +10214,7 @@ ppc64_elf_size_dynamic_sections (bfd *ou - - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { ---- a/bfd/elf64-s390.c -+++ b/bfd/elf64-s390.c -@@ -1301,7 +1301,7 @@ elf_s390_gc_mark_hook (asection *sec, - entry but we found we will not create any. Called when we find we will - not have any PLT for this symbol, by for example - elf_s390_adjust_dynamic_symbol when we're doing a proper dynamic link, -- or elf_s390_size_dynamic_sections if no dynamic sections will be -+ or elf_s390_late_size_sections if no dynamic sections will be - created (we're only linking static objects). */ - - static void -@@ -1714,8 +1714,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_s390_link_hash_table *htab; - bfd *dynobj; -@@ -1729,7 +1729,7 @@ elf_s390_size_dynamic_sections (bfd *out - - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -3881,7 +3881,7 @@ const struct elf_size_info s390_elf64_si - #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook - #define elf_backend_reloc_type_class elf_s390_reloc_type_class - #define elf_backend_relocate_section elf_s390_relocate_section --#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections -+#define elf_backend_late_size_sections elf_s390_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_grok_prstatus elf_s390_grok_prstatus - #define elf_backend_grok_psinfo elf_s390_grok_psinfo ---- a/bfd/elf64-sparc.c -+++ b/bfd/elf64-sparc.c -@@ -938,8 +938,8 @@ const struct elf_size_info elf64_sparc_s - _bfd_sparc_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym \ - _bfd_sparc_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections \ -- _bfd_sparc_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_sparc_elf_late_size_sections - #define elf_backend_relocate_section \ - _bfd_sparc_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf64-tilegx.c -+++ b/bfd/elf64-tilegx.c -@@ -106,7 +106,7 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_I - #define elf_backend_check_relocs tilegx_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol tilegx_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym tilegx_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections tilegx_elf_size_dynamic_sections -+#define elf_backend_late_size_sections tilegx_elf_late_size_sections - #define elf_backend_relocate_section tilegx_elf_relocate_section - #define elf_backend_finish_dynamic_symbol tilegx_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections tilegx_elf_finish_dynamic_sections ---- a/bfd/elf64-x86-64.c -+++ b/bfd/elf64-x86-64.c -@@ -2351,8 +2351,7 @@ elf_x86_64_scan_relocs (bfd *abfd, struc - } - - static bool --elf_x86_64_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf_x86_64_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *abfd; - -@@ -2365,7 +2364,7 @@ elf_x86_64_always_size_sections (bfd *ou - elf_x86_64_scan_relocs)) - return false; - -- return _bfd_x86_elf_always_size_sections (output_bfd, info); -+ return _bfd_x86_elf_early_size_sections (output_bfd, info); - } - - /* Return the relocation value for @tpoff relocation -@@ -5262,7 +5261,7 @@ elf_x86_64_special_sections[]= - elf_x86_64_reloc_name_lookup - - #define elf_backend_relocs_compatible elf_x86_64_relocs_compatible --#define elf_backend_always_size_sections elf_x86_64_always_size_sections -+#define elf_backend_early_size_sections elf_x86_64_early_size_sections - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections elf_x86_64_finish_dynamic_sections - #define elf_backend_finish_dynamic_symbol elf_x86_64_finish_dynamic_symbol ---- a/bfd/elflink.c -+++ b/bfd/elflink.c -@@ -6623,8 +6623,8 @@ bfd_elf_size_dynamic_sections (bfd *outp - - /* The backend may have to create some sections regardless of whether - we're dynamic or not. */ -- if (bed->elf_backend_always_size_sections -- && ! (*bed->elf_backend_always_size_sections) (output_bfd, info)) -+ if (bed->elf_backend_early_size_sections -+ && !bed->elf_backend_early_size_sections (output_bfd, info)) - return false; - - dynobj = elf_hash_table (info)->dynobj; -@@ -7360,9 +7360,8 @@ bfd_elf_size_dynamic_sections (bfd *outp - - /* The backend must work out the sizes of all the other dynamic - sections. */ -- if (dynobj != NULL -- && bed->elf_backend_size_dynamic_sections != NULL -- && ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info)) -+ if (bed->elf_backend_late_size_sections != NULL -+ && !bed->elf_backend_late_size_sections (output_bfd, info)) - return false; - - if (dynobj != NULL && elf_hash_table (info)->dynamic_sections_created) ---- a/bfd/elfn32-mips.c -+++ b/bfd/elfn32-mips.c -@@ -4127,10 +4127,8 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_mips_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_mips_elf_size_dynamic_sections -+#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections -+#define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elfnn-aarch64.c -+++ b/bfd/elfnn-aarch64.c -@@ -112,7 +112,7 @@ - allocate space for one relocation on the slot. Record the GOT offset - for this symbol. - -- elfNN_aarch64_size_dynamic_sections () -+ elfNN_aarch64_late_size_sections () - - Iterate all input BFDS, look for in the local symbol data structure - constructed earlier for local TLS symbols and allocate them double -@@ -8859,8 +8859,8 @@ elfNN_aarch64_allocate_local_ifunc_dynre - though ! */ - - static bool --elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elfNN_aarch64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_aarch64_link_hash_table *htab; - bfd *dynobj; -@@ -8871,7 +8871,8 @@ elfNN_aarch64_size_dynamic_sections (bfd - htab = elf_aarch64_hash_table ((info)); - dynobj = htab->root.dynobj; - -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -9273,8 +9274,8 @@ elfNN_aarch64_create_small_pltn_entry (s - _TLS_MODULE_BASE_, if needed. */ - - static bool --elfNN_aarch64_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elfNN_aarch64_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - asection *tls_sec; - -@@ -10009,8 +10010,8 @@ const struct elf_size_info elfNN_aarch64 - #define elf_backend_adjust_dynamic_symbol \ - elfNN_aarch64_adjust_dynamic_symbol - --#define elf_backend_always_size_sections \ -- elfNN_aarch64_always_size_sections -+#define elf_backend_early_size_sections \ -+ elfNN_aarch64_early_size_sections - - #define elf_backend_check_relocs \ - elfNN_aarch64_check_relocs -@@ -10059,8 +10060,8 @@ const struct elf_size_info elfNN_aarch64 - #define elf_backend_section_from_shdr \ - elfNN_aarch64_section_from_shdr - --#define elf_backend_size_dynamic_sections \ -- elfNN_aarch64_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elfNN_aarch64_late_size_sections - - #define elf_backend_size_info \ - elfNN_aarch64_size_info ---- a/bfd/elfnn-ia64.c -+++ b/bfd/elfnn-ia64.c -@@ -2986,8 +2986,8 @@ elfNN_ia64_adjust_dynamic_symbol (struct - } - - static bool --elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elfNN_ia64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elfNN_ia64_allocate_data data; - struct elfNN_ia64_link_hash_table *ia64_info; -@@ -2998,8 +2998,9 @@ elfNN_ia64_size_dynamic_sections (bfd *o - if (ia64_info == NULL) - return false; - dynobj = ia64_info->root.dynobj; -+ if (dynobj == NULL) -+ return true; - ia64_info->self_dtpmod_offset = (bfd_vma) -1; -- BFD_ASSERT(dynobj != NULL); - data.info = info; - - /* Set the contents of the .interp section to the interpreter. */ -@@ -5035,8 +5036,8 @@ ignore_errors (const char *fmt ATTRIBUTE - elfNN_ia64_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - elfNN_ia64_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- elfNN_ia64_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elfNN_ia64_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_relocate_section \ ---- a/bfd/elfnn-loongarch.c -+++ b/bfd/elfnn-loongarch.c -@@ -1169,8 +1169,8 @@ maybe_set_textrel (struct elf_link_hash_ - } - - static bool --loongarch_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+loongarch_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct loongarch_elf_link_hash_table *htab; - bfd *dynobj; -@@ -1180,7 +1180,8 @@ loongarch_elf_size_dynamic_sections (bfd - htab = loongarch_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -3251,7 +3252,7 @@ loongarch_elf_gc_mark_hook (asection *se - loongarch_elf_create_dynamic_sections - #define elf_backend_check_relocs loongarch_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol loongarch_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections loongarch_elf_size_dynamic_sections -+#define elf_backend_late_size_sections loongarch_elf_late_size_sections - #define elf_backend_relocate_section loongarch_elf_relocate_section - #define elf_backend_finish_dynamic_symbol loongarch_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections \ ---- a/bfd/elfnn-riscv.c -+++ b/bfd/elfnn-riscv.c -@@ -1376,7 +1376,7 @@ allocate_local_ifunc_dynrelocs (void **s - } - - static bool --riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+riscv_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct riscv_elf_link_hash_table *htab; - bfd *dynobj; -@@ -1386,7 +1386,8 @@ riscv_elf_size_dynamic_sections (bfd *ou - htab = riscv_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5256,7 +5257,7 @@ riscv_elf_merge_symbol_attribute (struct - #define elf_backend_create_dynamic_sections riscv_elf_create_dynamic_sections - #define elf_backend_check_relocs riscv_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol riscv_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections riscv_elf_size_dynamic_sections -+#define elf_backend_late_size_sections riscv_elf_late_size_sections - #define elf_backend_relocate_section riscv_elf_relocate_section - #define elf_backend_finish_dynamic_symbol riscv_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections riscv_elf_finish_dynamic_sections ---- a/bfd/elfxx-mips.c -+++ b/bfd/elfxx-mips.c -@@ -9550,8 +9550,8 @@ _bfd_mips_elf_adjust_dynamic_symbol (str - check for any mips16 stub sections that we can discard. */ - - bool --_bfd_mips_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_mips_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - asection *sect; - struct mips_elf_link_hash_table *htab; -@@ -9894,8 +9894,8 @@ mips_elf_set_plt_sym_value (struct mips_ - /* Set the sizes of the dynamic sections. */ - - bool --_bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_mips_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s, *sreldyn; -@@ -9905,7 +9905,8 @@ _bfd_mips_elf_size_dynamic_sections (bfd - htab = mips_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -14824,7 +14825,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_always_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_early_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf_External_ABIFlags_v0)); - - /* Skip this section later on (I don't think this currently -@@ -14883,7 +14884,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_always_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_early_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf32_External_RegInfo)); - - /* Skip this section later on (I don't think this currently ---- a/bfd/elfxx-mips.h -+++ b/bfd/elfxx-mips.h -@@ -52,9 +52,9 @@ extern bool _bfd_mips_elf_check_relocs - (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); - extern bool _bfd_mips_elf_adjust_dynamic_symbol - (struct bfd_link_info *, struct elf_link_hash_entry *); --extern bool _bfd_mips_elf_always_size_sections -+extern bool _bfd_mips_elf_early_size_sections - (bfd *, struct bfd_link_info *); --extern bool _bfd_mips_elf_size_dynamic_sections -+extern bool _bfd_mips_elf_late_size_sections - (bfd *, struct bfd_link_info *); - extern int _bfd_mips_elf_relocate_section - (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, ---- a/bfd/elfxx-sparc.c -+++ b/bfd/elfxx-sparc.c -@@ -2381,8 +2381,8 @@ _bfd_sparc_elf_omit_section_dynsym (bfd - /* Set the sizes of the dynamic sections. */ - - bool --_bfd_sparc_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_sparc_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct _bfd_sparc_elf_link_hash_table *htab; - bfd *dynobj; -@@ -2392,7 +2392,8 @@ _bfd_sparc_elf_size_dynamic_sections (bf - htab = _bfd_sparc_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { ---- a/bfd/elfxx-sparc.h -+++ b/bfd/elfxx-sparc.h -@@ -117,7 +117,7 @@ extern bool _bfd_sparc_elf_adjust_dynami - (struct bfd_link_info *, struct elf_link_hash_entry *); - extern bool _bfd_sparc_elf_omit_section_dynsym - (bfd *, struct bfd_link_info *, asection *); --extern bool _bfd_sparc_elf_size_dynamic_sections -+extern bool _bfd_sparc_elf_late_size_sections - (bfd *, struct bfd_link_info *); - extern bool _bfd_sparc_elf_new_section_hook - (bfd *, asection *); ---- a/bfd/elfxx-target.h -+++ b/bfd/elfxx-target.h -@@ -493,11 +493,11 @@ - #ifndef elf_backend_adjust_dynamic_symbol - #define elf_backend_adjust_dynamic_symbol 0 - #endif --#ifndef elf_backend_always_size_sections --#define elf_backend_always_size_sections 0 -+#ifndef elf_backend_early_size_sections -+#define elf_backend_early_size_sections 0 - #endif --#ifndef elf_backend_size_dynamic_sections --#define elf_backend_size_dynamic_sections 0 -+#ifndef elf_backend_late_size_sections -+#define elf_backend_late_size_sections 0 - #endif - #ifndef elf_backend_strip_zero_sized_dynamic_sections - #define elf_backend_strip_zero_sized_dynamic_sections 0 -@@ -853,8 +853,8 @@ static const struct elf_backend_data elf - elf_backend_check_directives, - elf_backend_notice_as_needed, - elf_backend_adjust_dynamic_symbol, -- elf_backend_always_size_sections, -- elf_backend_size_dynamic_sections, -+ elf_backend_early_size_sections, -+ elf_backend_late_size_sections, - elf_backend_strip_zero_sized_dynamic_sections, - elf_backend_init_index_section, - elf_backend_relocate_section, ---- a/bfd/elfxx-tilegx.c -+++ b/bfd/elfxx-tilegx.c -@@ -2430,8 +2430,8 @@ tilegx_elf_omit_section_dynsym (bfd *out - } - - bool --tilegx_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+tilegx_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct tilegx_elf_link_hash_table *htab; - bfd *dynobj; -@@ -2441,7 +2441,8 @@ tilegx_elf_size_dynamic_sections (bfd *o - htab = tilegx_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { ---- a/bfd/elfxx-tilegx.h -+++ b/bfd/elfxx-tilegx.h -@@ -57,7 +57,7 @@ tilegx_elf_omit_section_dynsym (bfd *, - asection *); - - extern bool --tilegx_elf_size_dynamic_sections (bfd *, struct bfd_link_info *); -+tilegx_elf_late_size_sections (bfd *, struct bfd_link_info *); - - extern int - tilegx_elf_relocate_section (bfd *, struct bfd_link_info *, ---- a/bfd/elfxx-x86.c -+++ b/bfd/elfxx-x86.c -@@ -2002,7 +2002,7 @@ _bfd_elf_x86_valid_reloc_p (asection *in - /* Set the sizes of the dynamic sections. */ - - bool --_bfd_x86_elf_size_dynamic_sections (bfd *output_bfd, -+_bfd_x86_elf_late_size_sections (bfd *output_bfd, - struct bfd_link_info *info) - { - struct elf_x86_link_hash_table *htab; -@@ -2018,7 +2018,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd - return false; - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - /* Set up .got offsets for local syms, and space for local dynamic - relocs. */ -@@ -2599,8 +2599,8 @@ _bfd_x86_elf_finish_dynamic_sections (bf - - - bool --_bfd_x86_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_x86_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - asection *tls_sec = elf_hash_table (info)->tls_sec; - ---- a/bfd/elfxx-x86.h -+++ b/bfd/elfxx-x86.h -@@ -807,13 +807,13 @@ extern bool _bfd_elf_x86_valid_reloc_p - const Elf_Internal_Rela *, struct elf_link_hash_entry *, - Elf_Internal_Sym *, Elf_Internal_Shdr *, bool *); - --extern bool _bfd_x86_elf_size_dynamic_sections -+extern bool _bfd_x86_elf_late_size_sections - (bfd *, struct bfd_link_info *); - - extern struct elf_x86_link_hash_table *_bfd_x86_elf_finish_dynamic_sections - (bfd *, struct bfd_link_info *); - --extern bool _bfd_x86_elf_always_size_sections -+extern bool _bfd_x86_elf_early_size_sections - (bfd *, struct bfd_link_info *); - - extern void _bfd_x86_elf_merge_symbol_attribute -@@ -885,8 +885,8 @@ extern void _bfd_x86_elf_link_report_rel - - #define elf_backend_check_relocs \ - _bfd_x86_elf_check_relocs --#define elf_backend_size_dynamic_sections \ -- _bfd_x86_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_x86_elf_late_size_sections - #define elf_backend_merge_symbol_attribute \ - _bfd_x86_elf_merge_symbol_attribute - #define elf_backend_copy_indirect_symbol \ ---- a/ld/emultempl/vms.em -+++ b/ld/emultempl/vms.em -@@ -196,10 +196,9 @@ gld${EMULATION_NAME}_before_allocation ( - - /* The backend must work out the sizes of all the other dynamic - sections. */ -- if (elf_hash_table (&link_info)->dynamic_sections_created -- && bed->elf_backend_size_dynamic_sections -- && ! (*bed->elf_backend_size_dynamic_sections) (link_info.output_bfd, -- &link_info)) -+ if (bed->elf_backend_late_size_sections -+ && !bed->elf_backend_late_size_sections (link_info.output_bfd, -+ &link_info)) - einfo (_("%F%P: failed to set dynamic section sizes: %E\n")); - - before_allocation_default (); diff --git a/toolchain/binutils/patches/2.38/002-PR-30569-delete-_bfd_mips_elf_early_size_sections.patch b/toolchain/binutils/patches/2.38/002-PR-30569-delete-_bfd_mips_elf_early_size_sections.patch deleted file mode 100644 index 725d676510..0000000000 --- a/toolchain/binutils/patches/2.38/002-PR-30569-delete-_bfd_mips_elf_early_size_sections.patch +++ /dev/null @@ -1,218 +0,0 @@ -From 3c6c32951e292a51ede70b8087bb0308d7dbc4fc Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Thu, 28 Mar 2024 20:33:32 +1030 -Subject: [PATCH 2/2] PR 30569, delete _bfd_mips_elf_early_size_sections - -PR30569 was triggered by a patch of mine 6540edd52cc0 moving the call -to always_size_sections in bfd_elf_size_dynamic_sections earlier, made -to support the x86 DT_RELR implementation. This broke mips16 code -handling stubs when --export-dynamic is passed to the linker, because -numerous symbols then became dynamic after always_size_sections. The -mips backend fiddles with symbols in its always_size_sections. Maciej -in 902e9fc76a0e had moved the call to always_size_sections to after -the export-dynamic code. Prior to that, Nathan in 04c3a75556c0 moved -it before the exec stack code, back to the start of -bfd_elf_size_dynamic_sections which was where Ian put it originally -in ff12f303355b. So the call has moved around a little. I'm leaving -it where it is, and instead calling mips_elf_check_symbols from -late_size_sections (the old size_dynamic_sections) which is now always -called. In fact, the whole of _bfd_mips_elf_early_size_sections can -be merged into _bfd_mips_elf_late_size_sections. ---- - bfd/elf32-mips.c | 1 - - bfd/elf64-mips.c | 2 -- - bfd/elfn32-mips.c | 1 - - bfd/elfxx-mips.c | 84 +++++++++++++++++++---------------------------- - bfd/elfxx-mips.h | 2 -- - 5 files changed, 34 insertions(+), 56 deletions(-) - ---- a/bfd/elf32-mips.c -+++ b/bfd/elf32-mips.c -@@ -2526,7 +2526,6 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections - #define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section ---- a/bfd/elf64-mips.c -+++ b/bfd/elf64-mips.c -@@ -4741,8 +4741,6 @@ const struct elf_size_info mips_elf64_si - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_early_size_sections \ -- _bfd_mips_elf_early_size_sections - #define elf_backend_late_size_sections \ - _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section ---- a/bfd/elfn32-mips.c -+++ b/bfd/elfn32-mips.c -@@ -4127,7 +4127,6 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections - #define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section ---- a/bfd/elfxx-mips.c -+++ b/bfd/elfxx-mips.c -@@ -9545,48 +9545,6 @@ _bfd_mips_elf_adjust_dynamic_symbol (str - return _bfd_elf_adjust_dynamic_copy (info, h, s); - } - --/* This function is called after all the input files have been read, -- and the input sections have been assigned to output sections. We -- check for any mips16 stub sections that we can discard. */ -- --bool --_bfd_mips_elf_early_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) --{ -- asection *sect; -- struct mips_elf_link_hash_table *htab; -- struct mips_htab_traverse_info hti; -- -- htab = mips_elf_hash_table (info); -- BFD_ASSERT (htab != NULL); -- -- /* The .reginfo section has a fixed size. */ -- sect = bfd_get_section_by_name (output_bfd, ".reginfo"); -- if (sect != NULL) -- { -- bfd_set_section_size (sect, sizeof (Elf32_External_RegInfo)); -- sect->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -- } -- -- /* The .MIPS.abiflags section has a fixed size. */ -- sect = bfd_get_section_by_name (output_bfd, ".MIPS.abiflags"); -- if (sect != NULL) -- { -- bfd_set_section_size (sect, sizeof (Elf_External_ABIFlags_v0)); -- sect->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -- } -- -- hti.info = info; -- hti.output_bfd = output_bfd; -- hti.error = false; -- mips_elf_link_hash_traverse (mips_elf_hash_table (info), -- mips_elf_check_symbols, &hti); -- if (hti.error) -- return false; -- -- return true; --} -- - /* If the link uses a GOT, lay it out and work out its size. */ - - static bool -@@ -9891,7 +9849,8 @@ mips_elf_set_plt_sym_value (struct mips_ - return true; - } - --/* Set the sizes of the dynamic sections. */ -+/* Set the sizes of the dynamic sections, some mips non-dynamic sections, -+ and check for any mips16 stub sections that we can discard. */ - - bool - _bfd_mips_elf_late_size_sections (bfd *output_bfd, -@@ -9901,14 +9860,39 @@ _bfd_mips_elf_late_size_sections (bfd *o - asection *s, *sreldyn; - bool reltext; - struct mips_elf_link_hash_table *htab; -+ struct mips_htab_traverse_info hti; - - htab = mips_elf_hash_table (info); - BFD_ASSERT (htab != NULL); -- dynobj = elf_hash_table (info)->dynobj; -+ -+ /* The .reginfo section has a fixed size. */ -+ s = bfd_get_section_by_name (output_bfd, ".reginfo"); -+ if (s != NULL) -+ { -+ bfd_set_section_size (s, sizeof (Elf32_External_RegInfo)); -+ s->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -+ } -+ -+ /* The .MIPS.abiflags section has a fixed size. */ -+ s = bfd_get_section_by_name (output_bfd, ".MIPS.abiflags"); -+ if (s != NULL) -+ { -+ bfd_set_section_size (s, sizeof (Elf_External_ABIFlags_v0)); -+ s->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -+ } -+ -+ hti.info = info; -+ hti.output_bfd = output_bfd; -+ hti.error = false; -+ mips_elf_link_hash_traverse (htab, mips_elf_check_symbols, &hti); -+ if (hti.error) -+ return false; -+ -+ dynobj = htab->root.dynobj; - if (dynobj == NULL) - return true; - -- if (elf_hash_table (info)->dynamic_sections_created) -+ if (htab->root.dynamic_sections_created) - { - /* Set the contents of the .interp section to the interpreter. */ - if (bfd_link_executable (info) && !info->nointerp) -@@ -10048,7 +10032,7 @@ _bfd_mips_elf_late_size_sections (bfd *o - } - } - else if (bfd_link_executable (info) -- && ! mips_elf_hash_table (info)->use_rld_obj_head -+ && !htab->use_rld_obj_head - && startswith (name, ".rld_map")) - { - /* We add a room for __rld_map. It will be filled in by the -@@ -10057,7 +10041,7 @@ _bfd_mips_elf_late_size_sections (bfd *o - } - else if (SGI_COMPAT (output_bfd) - && startswith (name, ".compact_rel")) -- s->size += mips_elf_hash_table (info)->compact_rel_size; -+ s->size += htab->compact_rel_size; - else if (s == htab->root.splt) - { - /* If the last PLT entry has a branch delay slot, allocate -@@ -10097,7 +10081,7 @@ _bfd_mips_elf_late_size_sections (bfd *o - } - } - -- if (elf_hash_table (info)->dynamic_sections_created) -+ if (htab->root.dynamic_sections_created) - { - /* Add some entries to the .dynamic section. We fill in the - values later, in _bfd_mips_elf_finish_dynamic_sections, but we -@@ -14825,7 +14809,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_early_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_late_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf_External_ABIFlags_v0)); - - /* Skip this section later on (I don't think this currently -@@ -14884,7 +14868,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_early_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_late_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf32_External_RegInfo)); - - /* Skip this section later on (I don't think this currently ---- a/bfd/elfxx-mips.h -+++ b/bfd/elfxx-mips.h -@@ -52,8 +52,6 @@ extern bool _bfd_mips_elf_check_relocs - (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); - extern bool _bfd_mips_elf_adjust_dynamic_symbol - (struct bfd_link_info *, struct elf_link_hash_entry *); --extern bool _bfd_mips_elf_early_size_sections -- (bfd *, struct bfd_link_info *); - extern bool _bfd_mips_elf_late_size_sections - (bfd *, struct bfd_link_info *); - extern int _bfd_mips_elf_relocate_section diff --git a/toolchain/binutils/patches/2.38/300-001_ld_makefile_patch.patch b/toolchain/binutils/patches/2.38/300-001_ld_makefile_patch.patch deleted file mode 100644 index ecc9dd64e3..0000000000 --- a/toolchain/binutils/patches/2.38/300-001_ld_makefile_patch.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/ld/Makefile.am -+++ b/ld/Makefile.am -@@ -50,7 +50,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) - - 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 diff --git a/toolchain/binutils/patches/2.38/400-mips_no_dynamic_linking_sym.patch b/toolchain/binutils/patches/2.38/400-mips_no_dynamic_linking_sym.patch deleted file mode 100644 index 070247ecf0..0000000000 --- a/toolchain/binutils/patches/2.38/400-mips_no_dynamic_linking_sym.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/bfd/elfxx-mips.c -+++ b/bfd/elfxx-mips.c -@@ -8057,6 +8057,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))) -@@ -8069,6 +8070,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) - { diff --git a/toolchain/binutils/patches/2.38/500-Change-default-emulation-for-mips64-linux.patch b/toolchain/binutils/patches/2.38/500-Change-default-emulation-for-mips64-linux.patch deleted file mode 100644 index 0797f4dff9..0000000000 --- a/toolchain/binutils/patches/2.38/500-Change-default-emulation-for-mips64-linux.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/bfd/config.bfd -+++ b/bfd/config.bfd -@@ -928,12 +928,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 -@@ -543,12 +543,12 @@ mips*-*-vxworks*) targ_emul=elf32ebmipvx - ;; - 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 diff --git a/toolchain/binutils/patches/2.39/001-PR-30569-always-call-elf_backend_size_dynamic_sectio.patch b/toolchain/binutils/patches/2.39/001-PR-30569-always-call-elf_backend_size_dynamic_sectio.patch deleted file mode 100644 index 84b99172f7..0000000000 --- a/toolchain/binutils/patches/2.39/001-PR-30569-always-call-elf_backend_size_dynamic_sectio.patch +++ /dev/null @@ -1,2172 +0,0 @@ -From af969b14aedcc0ae27dcefab4327ff2d153dec8b Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Thu, 28 Mar 2024 19:25:42 +1030 -Subject: [PATCH 1/2] PR 30569, always call elf_backend_size_dynamic_sections - -This largely mechanical patch is preparation for a followup patch. - -For quite some time I've thought that it would be useful to call -elf_backend_size_dynamic_sections even when no dynamic objects are -seen by the linker. That's what this patch does, with some renaming. -There are no functional changes to the linker, just a move of the -dynobj test in bfd_elf_size_dynamic_sections to target backend -functions, replacing the asserts/aborts already there. No doubt some -of the current always_size_sections functions could be moved to -size_dynamic_sections but I haven't made that change. - -Because both hooks are now always called, I have renamed -always_size_sections to early_size_sections and size_dynamic_sections -to late_size_sections. I condisdered calling late_size_sections plain -size_sections, since this is the usual target dynamic section sizing -hook, but decided that searching the sources for "size_sections" would -then hit early_size_sections and other functions. ---- - bfd/elf-bfd.h | 35 +++++++++++++++++------------------ - bfd/elf-m10300.c | 11 ++++++----- - bfd/elf32-arc.c | 9 +++++---- - bfd/elf32-arm.c | 15 ++++++++------- - bfd/elf32-bfin.c | 31 ++++++++++++++++--------------- - bfd/elf32-cr16.c | 11 ++++++----- - bfd/elf32-cris.c | 13 +++++++------ - bfd/elf32-csky.c | 8 ++++---- - bfd/elf32-frv.c | 23 ++++++++++++----------- - bfd/elf32-hppa.c | 8 ++++---- - bfd/elf32-i386.c | 7 +++---- - bfd/elf32-lm32.c | 15 ++++++++------- - bfd/elf32-m32c.c | 8 ++++---- - bfd/elf32-m32r.c | 11 ++++++----- - bfd/elf32-m68k.c | 16 ++++++++-------- - bfd/elf32-metag.c | 8 ++++---- - bfd/elf32-microblaze.c | 9 +++++---- - bfd/elf32-mips.c | 6 ++---- - bfd/elf32-nds32.c | 9 +++++---- - bfd/elf32-nios2.c | 15 ++++++++------- - bfd/elf32-or1k.c | 9 +++++---- - bfd/elf32-ppc.c | 11 ++++++----- - bfd/elf32-rl78.c | 8 ++++---- - bfd/elf32-s390.c | 10 +++++----- - bfd/elf32-score.c | 35 ++++++++++++++++++----------------- - bfd/elf32-score.h | 4 ++-- - bfd/elf32-score7.c | 13 +++++++------ - bfd/elf32-sh.c | 15 +++++++-------- - bfd/elf32-sparc.c | 3 +-- - bfd/elf32-tic6x.c | 14 +++++++------- - bfd/elf32-tilegx.c | 2 +- - bfd/elf32-tilepro.c | 11 +++++------ - bfd/elf32-vax.c | 16 +++++++--------- - bfd/elf32-xstormy16.c | 8 ++++---- - bfd/elf32-xtensa.c | 13 ++++++------- - bfd/elf64-alpha.c | 19 ++++++++++--------- - bfd/elf64-hppa.c | 11 ++++------- - bfd/elf64-ia64-vms.c | 13 +++++++------ - bfd/elf64-mips.c | 8 ++++---- - bfd/elf64-ppc.c | 12 ++++++------ - bfd/elf64-s390.c | 10 +++++----- - bfd/elf64-sparc.c | 4 ++-- - bfd/elf64-tilegx.c | 2 +- - bfd/elf64-x86-64.c | 7 +++---- - bfd/elflink.c | 9 ++++----- - bfd/elfn32-mips.c | 6 ++---- - bfd/elfnn-aarch64.c | 21 +++++++++++---------- - bfd/elfnn-ia64.c | 11 ++++++----- - bfd/elfnn-kvx.c | 19 +++++++++---------- - bfd/elfnn-loongarch.c | 9 +++++---- - bfd/elfnn-riscv.c | 7 ++++--- - bfd/elfxx-mips.c | 15 ++++++++------- - bfd/elfxx-mips.h | 4 ++-- - bfd/elfxx-sparc.c | 7 ++++--- - bfd/elfxx-sparc.h | 2 +- - bfd/elfxx-target.h | 12 ++++++------ - bfd/elfxx-tilegx.c | 7 ++++--- - bfd/elfxx-tilegx.h | 2 +- - bfd/elfxx-x86.c | 8 ++++---- - bfd/elfxx-x86.h | 8 ++++---- - ld/emultempl/vms.em | 7 +++---- - 61 files changed, 343 insertions(+), 337 deletions(-) - ---- a/bfd/elf-bfd.h -+++ b/bfd/elf-bfd.h -@@ -1136,7 +1136,7 @@ struct elf_backend_data - /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend - linker for every symbol which is defined by a dynamic object and - referenced by a regular object. This is called after all the -- input files have been seen, but before the SIZE_DYNAMIC_SECTIONS -+ input files have been seen, but before the LATE_SIZE_SECTIONS - function has been called. The hash table entry should be - bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be - defined in a section from a dynamic object. Dynamic object -@@ -1148,24 +1148,23 @@ struct elf_backend_data - bool (*elf_backend_adjust_dynamic_symbol) - (struct bfd_link_info *info, struct elf_link_hash_entry *h); - -- /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker -- after all the linker input files have been seen but before the -- section sizes have been set. This is called after -- ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS. */ -- bool (*elf_backend_always_size_sections) -+ /* The EARLY_SIZE_SECTIONS and LATE_SIZE_SECTIONS functions are -+ called by the backend linker after all linker input files have -+ been seen and sections have been assigned to output sections, but -+ before the section sizes have been set. Both of these functions -+ are called even when no dynamic object is seen by the linker. -+ Between them, they must set the sizes of the dynamic sections and -+ other backend specific sections, and may fill in their contents. -+ Most backends need only use LATE_SIZE_SECTIONS. -+ EARLY_SIZE_SECTIONS is called before --export-dynamic makes some -+ symbols dynamic and before ADJUST_DYNAMIC_SYMBOL processes -+ dynamic symbols, LATE_SIZE_SECTIONS afterwards. The generic ELF -+ linker can handle the .dynsym, .dynstr and .hash sections. -+ Besides those, these functions must handle the .interp section -+ and any other sections created by CREATE_DYNAMIC_SECTIONS. */ -+ bool (*elf_backend_early_size_sections) - (bfd *output_bfd, struct bfd_link_info *info); -- -- /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend -- linker after all the linker input files have been seen but before -- the sections sizes have been set. This is called after -- ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols. -- It is only called when linking against a dynamic object. It must -- set the sizes of the dynamic sections, and may fill in their -- contents as well. The generic ELF linker can handle the .dynsym, -- .dynstr and .hash sections. This function must handle the -- .interp section and any sections created by the -- CREATE_DYNAMIC_SECTIONS entry point. */ -- bool (*elf_backend_size_dynamic_sections) -+ bool (*elf_backend_late_size_sections) - (bfd *output_bfd, struct bfd_link_info *info); - - /* The STRIP_ZERO_SIZED_DYNAMIC_SECTIONS function is called by the ---- a/bfd/elf-m10300.c -+++ b/bfd/elf-m10300.c -@@ -5003,8 +5003,8 @@ _bfd_mn10300_elf_adjust_dynamic_symbol ( - /* Set the sizes of the dynamic sections. */ - - static bool --_bfd_mn10300_elf_size_dynamic_sections (bfd * output_bfd, -- struct bfd_link_info * info) -+_bfd_mn10300_elf_late_size_sections (bfd * output_bfd, -+ struct bfd_link_info * info) - { - struct elf32_mn10300_link_hash_table *htab = elf32_mn10300_hash_table (info); - bfd * dynobj; -@@ -5012,7 +5012,8 @@ _bfd_mn10300_elf_size_dynamic_sections ( - bool relocs; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5499,8 +5500,8 @@ mn10300_elf_mkobject (bfd *abfd) - _bfd_mn10300_elf_create_dynamic_sections - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mn10300_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- _bfd_mn10300_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_mn10300_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_symbol \ - _bfd_mn10300_elf_finish_dynamic_symbol ---- a/bfd/elf32-arc.c -+++ b/bfd/elf32-arc.c -@@ -2702,8 +2702,8 @@ elf_arc_finish_dynamic_sections (bfd * o - - /* Set the sizes of the dynamic sections. */ - static bool --elf_arc_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_arc_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -2711,7 +2711,8 @@ elf_arc_size_dynamic_sections (bfd *outp - struct elf_link_hash_table *htab = elf_hash_table (info); - - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->dynamic_sections_created) - { -@@ -3126,7 +3127,7 @@ arc_elf_relax_section (bfd *abfd, asecti - #define elf_backend_finish_dynamic_symbol elf_arc_finish_dynamic_symbol - - #define elf_backend_finish_dynamic_sections elf_arc_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf_arc_size_dynamic_sections -+#define elf_backend_late_size_sections elf_arc_late_size_sections - - #define elf_backend_can_gc_sections 1 - #define elf_backend_want_got_plt 1 ---- a/bfd/elf32-arm.c -+++ b/bfd/elf32-arm.c -@@ -16729,8 +16729,8 @@ bfd_elf32_arm_set_byteswap_code (struct - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info * info) -+elf32_arm_late_size_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info * info) - { - bfd * dynobj; - asection * s; -@@ -16743,7 +16743,9 @@ elf32_arm_size_dynamic_sections (bfd * o - return false; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; -+ - check_use_blx (htab); - - if (elf_hash_table (info)->dynamic_sections_created) -@@ -17115,8 +17117,7 @@ elf32_arm_size_dynamic_sections (bfd * o - _TLS_MODULE_BASE_, if needed. */ - - static bool --elf32_arm_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_arm_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - asection *tls_sec; - struct elf32_arm_link_hash_table *htab; -@@ -20283,8 +20284,8 @@ elf32_arm_backend_symbol_processing (bfd - #define elf_backend_create_dynamic_sections elf32_arm_create_dynamic_sections - #define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections --#define elf_backend_always_size_sections elf32_arm_always_size_sections -+#define elf_backend_late_size_sections elf32_arm_late_size_sections -+#define elf_backend_early_size_sections elf32_arm_early_size_sections - #define elf_backend_init_index_section _bfd_elf_init_2_index_sections - #define elf_backend_init_file_header elf32_arm_init_file_header - #define elf_backend_reloc_type_class elf32_arm_reloc_type_class ---- a/bfd/elf32-bfin.c -+++ b/bfd/elf32-bfin.c -@@ -4027,8 +4027,8 @@ _bfinfdpic_size_got_plt (bfd *output_bfd - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_bfinfdpic_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_bfinfdpic_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct elf_link_hash_table *htab; - bfd *dynobj; -@@ -4037,7 +4037,8 @@ elf32_bfinfdpic_size_dynamic_sections (b - - htab = elf_hash_table (info); - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->dynamic_sections_created) - { -@@ -4086,7 +4087,7 @@ elf32_bfinfdpic_size_dynamic_sections (b - } - - static bool --elf32_bfinfdpic_always_size_sections (bfd *output_bfd, -+elf32_bfinfdpic_early_size_sections (bfd *output_bfd, - struct bfd_link_info *info) - { - if (!bfd_link_relocatable (info) -@@ -5124,15 +5125,16 @@ bfin_discard_copies (struct elf_link_has - } - - static bool --bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+bfin_late_size_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5424,8 +5426,7 @@ struct bfd_elf_special_section const elf - #define elf_backend_check_relocs bfin_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - bfin_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- bfin_size_dynamic_sections -+#define elf_backend_late_size_sections bfin_late_size_sections - #define elf_backend_relocate_section bfin_relocate_section - #define elf_backend_finish_dynamic_symbol \ - bfin_finish_dynamic_symbol -@@ -5471,9 +5472,9 @@ struct bfd_elf_special_section const elf - #undef bfd_elf32_bfd_link_hash_table_create - #define bfd_elf32_bfd_link_hash_table_create \ - bfinfdpic_elf_link_hash_table_create --#undef elf_backend_always_size_sections --#define elf_backend_always_size_sections \ -- elf32_bfinfdpic_always_size_sections -+#undef elf_backend_early_size_sections -+#define elf_backend_early_size_sections \ -+ elf32_bfinfdpic_early_size_sections - - #undef elf_backend_create_dynamic_sections - #define elf_backend_create_dynamic_sections \ -@@ -5481,9 +5482,9 @@ struct bfd_elf_special_section const elf - #undef elf_backend_adjust_dynamic_symbol - #define elf_backend_adjust_dynamic_symbol \ - elf32_bfinfdpic_adjust_dynamic_symbol --#undef elf_backend_size_dynamic_sections --#define elf_backend_size_dynamic_sections \ -- elf32_bfinfdpic_size_dynamic_sections -+#undef elf_backend_late_size_sections -+#define elf_backend_late_size_sections \ -+ elf32_bfinfdpic_late_size_sections - #undef elf_backend_finish_dynamic_symbol - #define elf_backend_finish_dynamic_symbol \ - elf32_bfinfdpic_finish_dynamic_symbol ---- a/bfd/elf32-cr16.c -+++ b/bfd/elf32-cr16.c -@@ -2381,15 +2381,16 @@ _bfd_cr16_elf_adjust_dynamic_symbol (str - /* Set the sizes of the dynamic sections. */ - - static bool --_bfd_cr16_elf_size_dynamic_sections (bfd * output_bfd, -- struct bfd_link_info * info) -+_bfd_cr16_elf_late_size_sections (bfd * output_bfd, -+ struct bfd_link_info * info) - { - bfd * dynobj; - asection * s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -2826,8 +2827,8 @@ _bfd_cr16_elf_reloc_type_class (const st - _bfd_cr16_elf_create_dynamic_sections - #define elf_backend_adjust_dynamic_symbol \ - _bfd_cr16_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- _bfd_cr16_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_cr16_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_symbol \ - _bfd_cr16_elf_finish_dynamic_symbol ---- a/bfd/elf32-cris.c -+++ b/bfd/elf32-cris.c -@@ -2527,7 +2527,7 @@ cris_elf_plt_sym_val (bfd_vma i ATTRIBUT - entry but we found we will not create any. Called when we find we will - not have any PLT for this symbol, by for example - elf_cris_adjust_dynamic_symbol when we're doing a proper dynamic link, -- or elf_cris_size_dynamic_sections if no dynamic sections will be -+ or elf_cris_late_size_sections if no dynamic sections will be - created (we're only linking static objects). */ - - static bool -@@ -3508,8 +3508,8 @@ cris_elf_check_relocs (bfd *abfd, - /* Set the sizes of the dynamic sections. */ - - static bool --elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_cris_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_cris_link_hash_table * htab; - bfd *dynobj; -@@ -3521,7 +3521,8 @@ elf_cris_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -4090,8 +4091,8 @@ elf_cris_got_elt_size (bfd *abfd ATTRIBU - elf_cris_adjust_dynamic_symbol - #define elf_backend_copy_indirect_symbol \ - elf_cris_copy_indirect_symbol --#define elf_backend_size_dynamic_sections \ -- elf_cris_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elf_cris_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_finish_dynamic_symbol \ - elf_cris_finish_dynamic_symbol ---- a/bfd/elf32-csky.c -+++ b/bfd/elf32-csky.c -@@ -1893,8 +1893,8 @@ csky_allocate_dynrelocs (struct elf_link - /* Set the sizes of the dynamic sections. */ - - static bool --csky_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+csky_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct csky_elf_link_hash_table *htab; - bfd *dynobj; -@@ -1907,7 +1907,7 @@ csky_elf_size_dynamic_sections (bfd *out - return false; - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- return false; -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -5344,7 +5344,7 @@ elf32_csky_obj_attrs_handle_unknown (bfd - /* Dynamic relocate related API. */ - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_adjust_dynamic_symbol csky_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections csky_elf_size_dynamic_sections -+#define elf_backend_late_size_sections csky_elf_late_size_sections - #define elf_backend_finish_dynamic_symbol csky_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections csky_elf_finish_dynamic_sections - #define elf_backend_rela_normal 1 ---- a/bfd/elf32-frv.c -+++ b/bfd/elf32-frv.c -@@ -5423,15 +5423,16 @@ _frvfdpic_size_got_plt (bfd *output_bfd, - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_frvfdpic_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_frvfdpic_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - struct _frvfdpic_dynamic_got_plt_info gpinfo; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5472,8 +5473,8 @@ elf32_frvfdpic_size_dynamic_sections (bf - } - - static bool --elf32_frvfdpic_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_frvfdpic_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - if (!bfd_link_relocatable (info) - && !bfd_elf_stack_segment_size (output_bfd, info, -@@ -6817,9 +6818,9 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_In - #undef bfd_elf32_bfd_link_hash_table_create - #define bfd_elf32_bfd_link_hash_table_create \ - frvfdpic_elf_link_hash_table_create --#undef elf_backend_always_size_sections --#define elf_backend_always_size_sections \ -- elf32_frvfdpic_always_size_sections -+#undef elf_backend_early_size_sections -+#define elf_backend_early_size_sections \ -+ elf32_frvfdpic_early_size_sections - - #undef elf_backend_create_dynamic_sections - #define elf_backend_create_dynamic_sections \ -@@ -6827,9 +6828,9 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_In - #undef elf_backend_adjust_dynamic_symbol - #define elf_backend_adjust_dynamic_symbol \ - elf32_frvfdpic_adjust_dynamic_symbol --#undef elf_backend_size_dynamic_sections --#define elf_backend_size_dynamic_sections \ -- elf32_frvfdpic_size_dynamic_sections -+#undef elf_backend_late_size_sections -+#define elf_backend_late_size_sections \ -+ elf32_frvfdpic_late_size_sections - #undef bfd_elf32_bfd_relax_section - #define bfd_elf32_bfd_relax_section \ - elf32_frvfdpic_relax_section ---- a/bfd/elf32-hppa.c -+++ b/bfd/elf32-hppa.c -@@ -2042,8 +2042,8 @@ clobber_millicode_symbols (struct elf_li - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf32_hppa_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf32_hppa_link_hash_table *htab; - bfd *dynobj; -@@ -2057,7 +2057,7 @@ elf32_hppa_size_dynamic_sections (bfd *o - - dynobj = htab->etab.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->etab.dynamic_sections_created) - { -@@ -4450,7 +4450,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Inte - #define elf_backend_hide_symbol elf32_hppa_hide_symbol - #define elf_backend_finish_dynamic_symbol elf32_hppa_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections elf32_hppa_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf32_hppa_size_dynamic_sections -+#define elf_backend_late_size_sections elf32_hppa_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_gc_mark_hook elf32_hppa_gc_mark_hook - #define elf_backend_grok_prstatus elf32_hppa_grok_prstatus ---- a/bfd/elf32-i386.c -+++ b/bfd/elf32-i386.c -@@ -1932,8 +1932,7 @@ elf_i386_scan_relocs (bfd *abfd, - } - - static bool --elf_i386_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf_i386_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *abfd; - -@@ -1946,7 +1945,7 @@ elf_i386_always_size_sections (bfd *outp - elf_i386_scan_relocs)) - return false; - -- return _bfd_x86_elf_always_size_sections (output_bfd, info); -+ return _bfd_x86_elf_early_size_sections (output_bfd, info); - } - - /* Set the correct type for an x86 ELF section. We do this by the -@@ -4443,7 +4442,7 @@ elf_i386_link_setup_gnu_properties (stru - #define bfd_elf32_get_synthetic_symtab elf_i386_get_synthetic_symtab - - #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible --#define elf_backend_always_size_sections elf_i386_always_size_sections -+#define elf_backend_early_size_sections elf_i386_early_size_sections - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_fake_sections elf_i386_fake_sections - #define elf_backend_finish_dynamic_sections elf_i386_finish_dynamic_sections ---- a/bfd/elf32-lm32.c -+++ b/bfd/elf32-lm32.c -@@ -1906,8 +1906,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --lm32_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+lm32_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct elf_lm32_link_hash_table *htab; - bfd *dynobj; -@@ -1920,7 +1920,8 @@ lm32_elf_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -2309,7 +2310,7 @@ lm32_elf_create_dynamic_sections (bfd *a - } - - static bool --lm32_elf_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+lm32_elf_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - if (!bfd_link_relocatable (info)) - { -@@ -2395,7 +2396,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bf - #define bfd_elf32_bfd_link_hash_table_create lm32_elf_link_hash_table_create - #define elf_backend_check_relocs lm32_elf_check_relocs - #define elf_backend_reloc_type_class lm32_elf_reloc_type_class --#define elf_backend_size_dynamic_sections lm32_elf_size_dynamic_sections -+#define elf_backend_late_size_sections lm32_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_create_dynamic_sections lm32_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections lm32_elf_finish_dynamic_sections -@@ -2416,8 +2417,8 @@ lm32_elf_fdpic_copy_private_bfd_data (bf - #undef elf32_bed - #define elf32_bed elf32_lm32fdpic_bed - --#undef elf_backend_always_size_sections --#define elf_backend_always_size_sections lm32_elf_always_size_sections -+#undef elf_backend_early_size_sections -+#define elf_backend_early_size_sections lm32_elf_early_size_sections - #undef bfd_elf32_bfd_copy_private_bfd_data - #define bfd_elf32_bfd_copy_private_bfd_data lm32_elf_fdpic_copy_private_bfd_data - ---- a/bfd/elf32-m32c.c -+++ b/bfd/elf32-m32c.c -@@ -773,8 +773,8 @@ m32c_elf_finish_dynamic_sections (bfd *a - } - - static bool --m32c_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+m32c_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *splt; -@@ -2131,8 +2131,8 @@ _bfd_m32c_elf_eh_frame_address_size (bfd - #define elf_backend_check_relocs m32c_elf_check_relocs - #define elf_backend_object_p m32c_elf_object_p - #define elf_symbol_leading_char ('_') --#define elf_backend_always_size_sections \ -- m32c_elf_always_size_sections -+#define elf_backend_early_size_sections \ -+ m32c_elf_early_size_sections - #define elf_backend_finish_dynamic_sections \ - m32c_elf_finish_dynamic_sections - ---- a/bfd/elf32-m32r.c -+++ b/bfd/elf32-m32r.c -@@ -1958,8 +1958,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+m32r_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_link_hash_table *htab; - bfd *dynobj; -@@ -1968,7 +1968,7 @@ m32r_elf_size_dynamic_sections (bfd *out - bfd *ibfd; - - #ifdef DEBUG_PIC -- printf ("m32r_elf_size_dynamic_sections()\n"); -+ printf ("m32r_elf_late_size_sections()\n"); - #endif - - htab = m32r_elf_hash_table (info); -@@ -1976,7 +1976,8 @@ m32r_elf_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->dynamic_sections_created) - { -@@ -3658,7 +3659,7 @@ m32r_elf_reloc_type_class (const struct - - #define elf_backend_create_dynamic_sections m32r_elf_create_dynamic_sections - #define bfd_elf32_bfd_link_hash_table_create m32r_elf_link_hash_table_create --#define elf_backend_size_dynamic_sections m32r_elf_size_dynamic_sections -+#define elf_backend_late_size_sections m32r_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_sections m32r_elf_finish_dynamic_sections - #define elf_backend_adjust_dynamic_symbol m32r_elf_adjust_dynamic_symbol ---- a/bfd/elf32-m68k.c -+++ b/bfd/elf32-m68k.c -@@ -2934,7 +2934,7 @@ elf_m68k_get_plt_info (bfd *output_bfd) - It's a convenient place to determine the PLT style. */ - - static bool --elf_m68k_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf_m68k_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - /* Bind input BFDs to GOTs and calculate sizes of .got and .rela.got - sections. */ -@@ -3107,15 +3107,16 @@ elf_m68k_adjust_dynamic_symbol (struct b - /* Set the sizes of the dynamic sections. */ - - static bool --elf_m68k_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_m68k_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -4628,12 +4629,11 @@ elf_m68k_grok_psinfo (bfd *abfd, Elf_Int - #define bfd_elf32_bfd_final_link bfd_elf_final_link - - #define elf_backend_check_relocs elf_m68k_check_relocs --#define elf_backend_always_size_sections \ -- elf_m68k_always_size_sections -+#define elf_backend_early_size_sections \ -+ elf_m68k_early_size_sections - #define elf_backend_adjust_dynamic_symbol \ - elf_m68k_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- elf_m68k_size_dynamic_sections -+#define elf_backend_late_size_sections elf_m68k_late_size_sections - #define elf_backend_final_write_processing elf_m68k_final_write_processing - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section elf_m68k_relocate_section ---- a/bfd/elf32-metag.c -+++ b/bfd/elf32-metag.c -@@ -2717,8 +2717,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_metag_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_metag_link_hash_table *htab; - bfd *dynobj; -@@ -2729,7 +2729,7 @@ elf_metag_size_dynamic_sections (bfd *ou - htab = metag_link_hash_table (info); - dynobj = htab->etab.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->etab.dynamic_sections_created) - { -@@ -4019,7 +4019,7 @@ elf_metag_plt_sym_val (bfd_vma i, const - #define elf_backend_adjust_dynamic_symbol elf_metag_adjust_dynamic_symbol - #define elf_backend_finish_dynamic_symbol elf_metag_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections elf_metag_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf_metag_size_dynamic_sections -+#define elf_backend_late_size_sections elf_metag_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_init_file_header elf_metag_init_file_header ---- a/bfd/elf32-microblaze.c -+++ b/bfd/elf32-microblaze.c -@@ -2946,8 +2946,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+microblaze_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf32_mb_link_hash_table *htab; - bfd *dynobj; -@@ -2959,7 +2959,8 @@ microblaze_elf_size_dynamic_sections (bf - return false; - - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - /* Set up .got offsets for local syms, and space for local dynamic - relocs. */ -@@ -3477,7 +3478,7 @@ microblaze_elf_add_symbol_hook (bfd *abf - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections microblaze_elf_finish_dynamic_sections - #define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol --#define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections -+#define elf_backend_late_size_sections microblaze_elf_late_size_sections - #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook - - #include "elf32-target.h" ---- a/bfd/elf32-mips.c -+++ b/bfd/elf32-mips.c -@@ -2525,10 +2525,8 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_mips_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_mips_elf_size_dynamic_sections -+#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections -+#define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf32-nds32.c -+++ b/bfd/elf32-nds32.c -@@ -4302,8 +4302,8 @@ elf32_nds32_add_dynreloc (bfd *output_bf - /* Set the sizes of the dynamic sections. */ - - static bool --nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+nds32_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_nds32_link_hash_table *htab; - bfd *dynobj; -@@ -4316,7 +4316,8 @@ nds32_elf_size_dynamic_sections (bfd *ou - return false; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -13984,7 +13985,7 @@ nds32_elf_unify_tls_model (bfd *inbfd, a - #define elf_backend_create_dynamic_sections nds32_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections nds32_elf_finish_dynamic_sections - #define elf_backend_finish_dynamic_symbol nds32_elf_finish_dynamic_symbol --#define elf_backend_size_dynamic_sections nds32_elf_size_dynamic_sections -+#define elf_backend_late_size_sections nds32_elf_late_size_sections - #define elf_backend_relocate_section nds32_elf_relocate_section - #define elf_backend_gc_mark_hook nds32_elf_gc_mark_hook - #define elf_backend_grok_prstatus nds32_elf_grok_prstatus ---- a/bfd/elf32-nios2.c -+++ b/bfd/elf32-nios2.c -@@ -5411,7 +5411,7 @@ nios2_elf32_adjust_dynamic_symbol (struc - return true; - } - --/* Worker function for nios2_elf32_size_dynamic_sections. */ -+/* Worker function for nios2_elf32_late_size_sections. */ - static bool - adjust_dynrelocs (struct elf_link_hash_entry *h, void *inf) - { -@@ -5438,7 +5438,7 @@ adjust_dynrelocs (struct elf_link_hash_e - return true; - } - --/* Another worker function for nios2_elf32_size_dynamic_sections. -+/* Another worker function for nios2_elf32_late_size_sections. - Allocate space in .plt, .got and associated reloc sections for - dynamic relocs. */ - static bool -@@ -5673,11 +5673,11 @@ allocate_dynrelocs (struct elf_link_hash - return true; - } - --/* Implement elf_backend_size_dynamic_sections: -+/* Implement elf_backend_late_size_sections: - Set the sizes of the dynamic sections. */ - static bool --nios2_elf32_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+nios2_elf32_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -5687,7 +5687,8 @@ nios2_elf32_size_dynamic_sections (bfd * - - htab = elf32_nios2_hash_table (info); - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - htab->res_n_size = 0; - if (htab->root.dynamic_sections_created) -@@ -6058,7 +6059,7 @@ const struct bfd_elf_special_section elf - nios2_elf32_finish_dynamic_sections - #define elf_backend_adjust_dynamic_symbol nios2_elf32_adjust_dynamic_symbol - #define elf_backend_reloc_type_class nios2_elf32_reloc_type_class --#define elf_backend_size_dynamic_sections nios2_elf32_size_dynamic_sections -+#define elf_backend_late_size_sections nios2_elf32_late_size_sections - #define elf_backend_add_symbol_hook nios2_elf_add_symbol_hook - #define elf_backend_copy_indirect_symbol nios2_elf32_copy_indirect_symbol - #define elf_backend_object_p nios2_elf32_object_p ---- a/bfd/elf32-or1k.c -+++ b/bfd/elf32-or1k.c -@@ -3039,8 +3039,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+or1k_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_or1k_link_hash_table *htab; - bfd *dynobj; -@@ -3053,7 +3053,8 @@ or1k_elf_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -3406,7 +3407,7 @@ or1k_grok_psinfo (bfd *abfd, Elf_Interna - #define elf_backend_copy_indirect_symbol or1k_elf_copy_indirect_symbol - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections or1k_elf_finish_dynamic_sections --#define elf_backend_size_dynamic_sections or1k_elf_size_dynamic_sections -+#define elf_backend_late_size_sections or1k_elf_late_size_sections - #define elf_backend_adjust_dynamic_symbol or1k_elf_adjust_dynamic_symbol - #define elf_backend_finish_dynamic_symbol or1k_elf_finish_dynamic_symbol - ---- a/bfd/elf32-ppc.c -+++ b/bfd/elf32-ppc.c -@@ -5477,8 +5477,8 @@ static const unsigned char glink_eh_fram - /* Set the sizes of the dynamic sections. */ - - static bool --ppc_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+ppc_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct ppc_elf_link_hash_table *htab; - asection *s; -@@ -5486,11 +5486,12 @@ ppc_elf_size_dynamic_sections (bfd *outp - bfd *ibfd; - - #ifdef DEBUG -- fprintf (stderr, "ppc_elf_size_dynamic_sections called\n"); -+ fprintf (stderr, "ppc_elf_late_size_sections called\n"); - #endif - - htab = ppc_elf_hash_table (info); -- BFD_ASSERT (htab->elf.dynobj != NULL); -+ if (htab->elf.dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -10414,7 +10415,7 @@ ppc_elf_finish_dynamic_sections (bfd *ou - #define elf_backend_copy_indirect_symbol ppc_elf_copy_indirect_symbol - #define elf_backend_adjust_dynamic_symbol ppc_elf_adjust_dynamic_symbol - #define elf_backend_add_symbol_hook ppc_elf_add_symbol_hook --#define elf_backend_size_dynamic_sections ppc_elf_size_dynamic_sections -+#define elf_backend_late_size_sections ppc_elf_late_size_sections - #define elf_backend_hash_symbol ppc_elf_hash_symbol - #define elf_backend_finish_dynamic_symbol ppc_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections ppc_elf_finish_dynamic_sections ---- a/bfd/elf32-rl78.c -+++ b/bfd/elf32-rl78.c -@@ -1440,8 +1440,8 @@ rl78_elf_finish_dynamic_sections (bfd *a - } - - static bool --rl78_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+rl78_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *splt; -@@ -2609,8 +2609,8 @@ rl78_elf_relax_section (bfd *abfd, - - #define bfd_elf32_bfd_relax_section rl78_elf_relax_section - #define elf_backend_check_relocs rl78_elf_check_relocs --#define elf_backend_always_size_sections \ -- rl78_elf_always_size_sections -+#define elf_backend_early_size_sections \ -+ rl78_elf_early_size_sections - #define elf_backend_finish_dynamic_sections \ - rl78_elf_finish_dynamic_sections - ---- a/bfd/elf32-s390.c -+++ b/bfd/elf32-s390.c -@@ -1366,7 +1366,7 @@ elf_s390_gc_mark_hook (asection *sec, - entry but we found we will not create any. Called when we find we will - not have any PLT for this symbol, by for example - elf_s390_adjust_dynamic_symbol when we're doing a proper dynamic link, -- or elf_s390_size_dynamic_sections if no dynamic sections will be -+ or elf_s390_late_size_sections if no dynamic sections will be - created (we're only linking static objects). */ - - static void -@@ -1778,8 +1778,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_s390_link_hash_table *htab; - bfd *dynobj; -@@ -1790,7 +1790,7 @@ elf_s390_size_dynamic_sections (bfd *out - htab = elf_s390_hash_table (info); - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -3926,7 +3926,7 @@ elf32_s390_merge_private_bfd_data (bfd * - #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook - #define elf_backend_reloc_type_class elf_s390_reloc_type_class - #define elf_backend_relocate_section elf_s390_relocate_section --#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections -+#define elf_backend_late_size_sections elf_s390_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_grok_prstatus elf_s390_grok_prstatus - #define elf_backend_grok_psinfo elf_s390_grok_psinfo ---- a/bfd/elf32-score.c -+++ b/bfd/elf32-score.c -@@ -1089,7 +1089,7 @@ score_elf_got_info (bfd *abfd, asection - appear towards the end. This reduces the amount of GOT space - required. MAX_LOCAL is used to set the number of local symbols - known to be in the dynamic symbol table. During -- s3_bfd_score_elf_size_dynamic_sections, this value is 1. Afterward, the -+ s3_bfd_score_elf_late_size_sections, this value is 1. Afterward, the - section symbols are added and the count is higher. */ - static bool - score_elf_sort_hash_table (struct bfd_link_info *info, -@@ -3160,8 +3160,8 @@ s3_bfd_score_elf_adjust_dynamic_symbol ( - /* This function is called after all the input files have been read, - and the input sections have been assigned to output sections. */ - static bool --s3_bfd_score_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+s3_bfd_score_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -3237,14 +3237,15 @@ s3_bfd_score_elf_always_size_sections (b - - /* Set the sizes of the dynamic sections. */ - static bool --s3_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+s3_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool reltext; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -3313,7 +3314,7 @@ s3_bfd_score_elf_size_dynamic_sections ( - } - else if (startswith (name, ".got")) - { -- /* s3_bfd_score_elf_always_size_sections() has already done -+ /* s3_bfd_score_elf_early_size_sections() has already done - most of the work, but some symbols may have been mapped - to versions that we must now resolve in the got_entries - hash tables. */ -@@ -4177,22 +4178,22 @@ _bfd_score_elf_adjust_dynamic_symbol (st - } - - static bool --_bfd_score_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_score_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - if (bfd_get_mach (output_bfd) == bfd_mach_score3) -- return s3_bfd_score_elf_always_size_sections (output_bfd, info); -+ return s3_bfd_score_elf_early_size_sections (output_bfd, info); - else -- return s7_bfd_score_elf_always_size_sections (output_bfd, info); -+ return s7_bfd_score_elf_early_size_sections (output_bfd, info); - } - - static bool --_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - if (bfd_get_mach (output_bfd) == bfd_mach_score3) -- return s3_bfd_score_elf_size_dynamic_sections (output_bfd, info); -+ return s3_bfd_score_elf_late_size_sections (output_bfd, info); - else -- return s7_bfd_score_elf_size_dynamic_sections (output_bfd, info); -+ return s7_bfd_score_elf_late_size_sections (output_bfd, info); - } - - static bool -@@ -4455,10 +4456,10 @@ _bfd_score_elf_common_definition (Elf_In - _bfd_score_elf_section_from_bfd_section - #define elf_backend_adjust_dynamic_symbol \ - _bfd_score_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_score_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_score_elf_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ _bfd_score_elf_early_size_sections -+#define elf_backend_late_size_sections \ -+ _bfd_score_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_create_dynamic_sections \ - _bfd_score_elf_create_dynamic_sections ---- a/bfd/elf32-score.h -+++ b/bfd/elf32-score.h -@@ -78,10 +78,10 @@ s7_bfd_score_elf_adjust_dynamic_symbol ( - struct elf_link_hash_entry *); - - extern bool --s7_bfd_score_elf_always_size_sections (bfd *, struct bfd_link_info *); -+s7_bfd_score_elf_early_size_sections (bfd *, struct bfd_link_info *); - - extern bool --s7_bfd_score_elf_size_dynamic_sections (bfd *, struct bfd_link_info *); -+s7_bfd_score_elf_late_size_sections (bfd *, struct bfd_link_info *); - - extern bool - s7_bfd_score_elf_create_dynamic_sections (bfd *, struct bfd_link_info *); ---- a/bfd/elf32-score7.c -+++ b/bfd/elf32-score7.c -@@ -975,7 +975,7 @@ score_elf_got_info (bfd *abfd, asection - appear towards the end. This reduces the amount of GOT space - required. MAX_LOCAL is used to set the number of local symbols - known to be in the dynamic symbol table. During -- s7_bfd_score_elf_size_dynamic_sections, this value is 1. Afterward, the -+ s7_bfd_score_elf_late_size_sections, this value is 1. Afterward, the - section symbols are added and the count is higher. */ - - static bool -@@ -2969,8 +2969,8 @@ s7_bfd_score_elf_adjust_dynamic_symbol ( - and the input sections have been assigned to output sections. */ - - bool --s7_bfd_score_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+s7_bfd_score_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -3047,14 +3047,15 @@ s7_bfd_score_elf_always_size_sections (b - /* Set the sizes of the dynamic sections. */ - - bool --s7_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+s7_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool reltext; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -3123,7 +3124,7 @@ s7_bfd_score_elf_size_dynamic_sections ( - } - else if (startswith (name, ".got")) - { -- /* s7_bfd_score_elf_always_size_sections() has already done -+ /* s7_bfd_score_elf_early_size_sections() has already done - most of the work, but some symbols may have been mapped - to versions that we must now resolve in the got_entries - hash tables. */ ---- a/bfd/elf32-sh.c -+++ b/bfd/elf32-sh.c -@@ -2925,7 +2925,7 @@ allocate_dynrelocs (struct elf_link_hash - It's a convenient place to determine the PLT style. */ - - static bool --sh_elf_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+sh_elf_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - sh_elf_hash_table (info)->plt_info = get_plt_info (output_bfd, - bfd_link_pic (info)); -@@ -2940,8 +2940,8 @@ sh_elf_always_size_sections (bfd *output - /* Set the sizes of the dynamic sections. */ - - static bool --sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+sh_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_sh_link_hash_table *htab; - bfd *dynobj; -@@ -2954,7 +2954,8 @@ sh_elf_size_dynamic_sections (bfd *outpu - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -6589,10 +6590,8 @@ sh_elf_encode_eh_address (bfd *abfd, - sh_elf_link_hash_table_create - #define elf_backend_adjust_dynamic_symbol \ - sh_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- sh_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- sh_elf_size_dynamic_sections -+#define elf_backend_early_size_sections sh_elf_early_size_sections -+#define elf_backend_late_size_sections sh_elf_late_size_sections - #define elf_backend_omit_section_dynsym sh_elf_omit_section_dynsym - #define elf_backend_finish_dynamic_symbol \ - sh_elf_finish_dynamic_symbol ---- a/bfd/elf32-sparc.c -+++ b/bfd/elf32-sparc.c -@@ -248,8 +248,7 @@ elf32_sparc_reloc_type_class (const stru - #define elf_backend_adjust_dynamic_symbol \ - _bfd_sparc_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym _bfd_sparc_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections \ -- _bfd_sparc_elf_size_dynamic_sections -+#define elf_backend_late_size_sections _bfd_sparc_elf_late_size_sections - #define elf_backend_relocate_section _bfd_sparc_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ - _bfd_sparc_elf_finish_dynamic_symbol ---- a/bfd/elf32-tic6x.c -+++ b/bfd/elf32-tic6x.c -@@ -3160,7 +3160,7 @@ elf32_tic6x_allocate_dynrelocs (struct e - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_tic6x_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf32_tic6x_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct elf32_tic6x_link_hash_table *htab; - bfd *dynobj; -@@ -3171,7 +3171,7 @@ elf32_tic6x_size_dynamic_sections (bfd * - htab = elf32_tic6x_hash_table (info); - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -3358,7 +3358,7 @@ elf32_tic6x_size_dynamic_sections (bfd * - and the input sections have been assigned to output sections. */ - - static bool --elf32_tic6x_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf32_tic6x_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - if (elf32_tic6x_using_dsbt (output_bfd) && !bfd_link_relocatable (info) - && !bfd_elf_stack_segment_size (output_bfd, info, -@@ -4261,10 +4261,10 @@ elf32_tic6x_write_section (bfd *output_b - #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible - #define elf_backend_finish_dynamic_symbol \ - elf32_tic6x_finish_dynamic_symbol --#define elf_backend_always_size_sections \ -- elf32_tic6x_always_size_sections --#define elf_backend_size_dynamic_sections \ -- elf32_tic6x_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ elf32_tic6x_early_size_sections -+#define elf_backend_late_size_sections \ -+ elf32_tic6x_late_size_sections - #define elf_backend_finish_dynamic_sections \ - elf32_tic6x_finish_dynamic_sections - #define bfd_elf32_bfd_final_link \ ---- a/bfd/elf32-tilegx.c -+++ b/bfd/elf32-tilegx.c -@@ -105,7 +105,7 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_I - #define elf_backend_check_relocs tilegx_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol tilegx_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym tilegx_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections tilegx_elf_size_dynamic_sections -+#define elf_backend_late_size_sections tilegx_elf_late_size_sections - #define elf_backend_relocate_section tilegx_elf_relocate_section - #define elf_backend_finish_dynamic_symbol tilegx_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections tilegx_elf_finish_dynamic_sections ---- a/bfd/elf32-tilepro.c -+++ b/bfd/elf32-tilepro.c -@@ -2182,11 +2182,9 @@ tilepro_elf_omit_section_dynsym (bfd *ou - #define ELF32_DYNAMIC_INTERPRETER "/lib/ld.so.1" - - static bool --tilepro_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+tilepro_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { -- (void)output_bfd; -- - struct elf_link_hash_table *htab; - bfd *dynobj; - asection *s; -@@ -2195,7 +2193,8 @@ tilepro_elf_size_dynamic_sections (bfd * - htab = tilepro_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -3739,7 +3738,7 @@ tilepro_additional_program_headers (bfd - #define elf_backend_check_relocs tilepro_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol tilepro_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym tilepro_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections tilepro_elf_size_dynamic_sections -+#define elf_backend_late_size_sections tilepro_elf_late_size_sections - #define elf_backend_relocate_section tilepro_elf_relocate_section - #define elf_backend_finish_dynamic_symbol tilepro_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections tilepro_elf_finish_dynamic_sections ---- a/bfd/elf32-vax.c -+++ b/bfd/elf32-vax.c -@@ -36,7 +36,6 @@ static bool elf_vax_check_relocs (bfd *, - asection *, const Elf_Internal_Rela *); - static bool elf_vax_adjust_dynamic_symbol (struct bfd_link_info *, - struct elf_link_hash_entry *); --static bool elf_vax_size_dynamic_sections (bfd *, struct bfd_link_info *); - static int elf_vax_relocate_section (bfd *, struct bfd_link_info *, - bfd *, asection *, bfd_byte *, - Elf_Internal_Rela *, -@@ -985,8 +984,8 @@ elf_vax_discard_got_entries (struct elf_ - /* Discard unused dynamic data if this is a static link. */ - - static bool --elf_vax_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_vax_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -1024,14 +1023,15 @@ elf_vax_always_size_sections (bfd *outpu - /* Set the sizes of the dynamic sections. */ - - static bool --elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf_vax_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -1861,10 +1861,8 @@ elf_vax_plt_sym_val (bfd_vma i, const as - #define elf_backend_check_relocs elf_vax_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - elf_vax_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- elf_vax_always_size_sections --#define elf_backend_size_dynamic_sections \ -- elf_vax_size_dynamic_sections -+#define elf_backend_early_size_sections elf_vax_early_size_sections -+#define elf_backend_late_size_sections elf_vax_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section elf_vax_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf32-xstormy16.c -+++ b/bfd/elf32-xstormy16.c -@@ -706,8 +706,8 @@ xstormy16_elf_relax_section (bfd *dynobj - } - - static bool --xstormy16_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+xstormy16_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *splt; -@@ -1013,8 +1013,8 @@ xstormy16_elf_gc_mark_hook (asection *se - #define elf_backend_relocate_section xstormy16_elf_relocate_section - #define elf_backend_gc_mark_hook xstormy16_elf_gc_mark_hook - #define elf_backend_check_relocs xstormy16_elf_check_relocs --#define elf_backend_always_size_sections \ -- xstormy16_elf_always_size_sections -+#define elf_backend_early_size_sections \ -+ xstormy16_elf_early_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_sections \ ---- a/bfd/elf32-xtensa.c -+++ b/bfd/elf32-xtensa.c -@@ -1568,8 +1568,8 @@ elf_xtensa_allocate_local_got_size (stru - /* Set the sizes of the dynamic sections. */ - - static bool --elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_xtensa_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_xtensa_link_hash_table *htab; - bfd *dynobj, *abfd; -@@ -1586,7 +1586,7 @@ elf_xtensa_size_dynamic_sections (bfd *o - - dynobj = elf_hash_table (info)->dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - srelgot = htab->elf.srelgot; - srelplt = htab->elf.srelplt; - -@@ -1791,8 +1791,7 @@ elf_xtensa_size_dynamic_sections (bfd *o - } - - static bool --elf_xtensa_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf_xtensa_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct elf_xtensa_link_hash_table *htab; - asection *tls_sec; -@@ -11551,8 +11550,8 @@ static const struct bfd_elf_special_sect - #define elf_backend_object_p elf_xtensa_object_p - #define elf_backend_reloc_type_class elf_xtensa_reloc_type_class - #define elf_backend_relocate_section elf_xtensa_relocate_section --#define elf_backend_size_dynamic_sections elf_xtensa_size_dynamic_sections --#define elf_backend_always_size_sections elf_xtensa_always_size_sections -+#define elf_backend_late_size_sections elf_xtensa_late_size_sections -+#define elf_backend_early_size_sections elf_xtensa_early_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_special_sections elf_xtensa_special_sections - #define elf_backend_action_discarded elf_xtensa_action_discarded ---- a/bfd/elf64-alpha.c -+++ b/bfd/elf64-alpha.c -@@ -2579,8 +2579,8 @@ elf64_alpha_size_plt_section (struct bfd - } - - static bool --elf64_alpha_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf64_alpha_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *i; - struct alpha_elf_link_hash_table * htab; -@@ -2806,8 +2806,8 @@ elf64_alpha_size_rela_got_section (struc - /* Set the sizes of the dynamic sections. */ - - static bool --elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf64_alpha_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -2819,7 +2819,8 @@ elf64_alpha_size_dynamic_sections (bfd * - return false; - - dynobj = elf_hash_table(info)->dynobj; -- BFD_ASSERT(dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5465,10 +5466,10 @@ static const struct elf_size_info alpha_ - elf64_alpha_merge_symbol_attribute - #define elf_backend_copy_indirect_symbol \ - elf64_alpha_copy_indirect_symbol --#define elf_backend_always_size_sections \ -- elf64_alpha_always_size_sections --#define elf_backend_size_dynamic_sections \ -- elf64_alpha_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ elf64_alpha_early_size_sections -+#define elf_backend_late_size_sections \ -+ elf64_alpha_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_relocate_section \ ---- a/bfd/elf64-hppa.c -+++ b/bfd/elf64-hppa.c -@@ -176,9 +176,6 @@ static bool elf64_hppa_adjust_dynamic_sy - static bool elf64_hppa_mark_milli_and_exported_functions - (struct elf_link_hash_entry *, void *); - --static bool elf64_hppa_size_dynamic_sections -- (bfd *, struct bfd_link_info *); -- - static int elf64_hppa_link_output_symbol_hook - (struct bfd_link_info *, const char *, Elf_Internal_Sym *, - asection *, struct elf_link_hash_entry *); -@@ -1520,7 +1517,7 @@ elf64_hppa_mark_milli_and_exported_funct - the contents of our special sections. */ - - static bool --elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf64_hppa_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct elf64_hppa_link_hash_table *hppa_info; - struct elf64_hppa_allocate_data data; -@@ -1534,7 +1531,8 @@ elf64_hppa_size_dynamic_sections (bfd *o - return false; - - dynobj = hppa_info->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - /* Mark each function this program exports so that we will allocate - space in the .opd section for each function's FPTR. If we are -@@ -3984,8 +3982,7 @@ const struct elf_size_info hppa64_elf_si - #define elf_backend_adjust_dynamic_symbol \ - elf64_hppa_adjust_dynamic_symbol - --#define elf_backend_size_dynamic_sections \ -- elf64_hppa_size_dynamic_sections -+#define elf_backend_late_size_sections elf64_hppa_late_size_sections - - #define elf_backend_finish_dynamic_symbol \ - elf64_hppa_finish_dynamic_symbol ---- a/bfd/elf64-ia64-vms.c -+++ b/bfd/elf64-ia64-vms.c -@@ -2590,8 +2590,8 @@ elf64_ia64_adjust_dynamic_symbol (struct - } - - static bool --elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf64_ia64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf64_ia64_allocate_data data; - struct elf64_ia64_link_hash_table *ia64_info; -@@ -2600,11 +2600,12 @@ elf64_ia64_size_dynamic_sections (bfd *o - struct elf_link_hash_table *hash_table; - - hash_table = elf_hash_table (info); -- dynobj = hash_table->dynobj; - ia64_info = elf64_ia64_hash_table (info); - if (ia64_info == NULL) - return false; -- BFD_ASSERT(dynobj != NULL); -+ dynobj = hash_table->dynobj; -+ if (dynobj == NULL) -+ return true; - data.info = info; - - /* Allocate the GOT entries. */ -@@ -5484,8 +5485,8 @@ static const struct elf_size_info elf64_ - elf64_ia64_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - elf64_ia64_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- elf64_ia64_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elf64_ia64_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_relocate_section \ ---- a/bfd/elf64-mips.c -+++ b/bfd/elf64-mips.c -@@ -4739,10 +4739,10 @@ const struct elf_size_info mips_elf64_si - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_mips_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_mips_elf_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ _bfd_mips_elf_early_size_sections -+#define elf_backend_late_size_sections \ -+ _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf64-ppc.c -+++ b/bfd/elf64-ppc.c -@@ -118,8 +118,8 @@ static bfd_vma opd_entry_value - #define elf_backend_adjust_dynamic_symbol ppc64_elf_adjust_dynamic_symbol - #define elf_backend_hide_symbol ppc64_elf_hide_symbol - #define elf_backend_maybe_function_sym ppc64_elf_maybe_function_sym --#define elf_backend_always_size_sections ppc64_elf_edit --#define elf_backend_size_dynamic_sections ppc64_elf_size_dynamic_sections -+#define elf_backend_early_size_sections ppc64_elf_edit -+#define elf_backend_late_size_sections ppc64_elf_late_size_sections - #define elf_backend_hash_symbol ppc64_elf_hash_symbol - #define elf_backend_init_index_section _bfd_elf_init_2_index_sections - #define elf_backend_action_discarded ppc64_elf_action_discarded -@@ -10117,7 +10117,7 @@ allocate_dynrelocs (struct elf_link_hash - ((((v) & 0x3ffff0000ULL) << 16) | (v & 0xffff)) - #define HA34(v) ((v + (1ULL << 33)) >> 34) - --/* Called via elf_link_hash_traverse from ppc64_elf_size_dynamic_sections -+/* Called via elf_link_hash_traverse from ppc64_elf_late_size_sections - to set up space for global entry stubs. These are put in glink, - after the branch table. */ - -@@ -10194,8 +10194,8 @@ size_global_entry_stubs (struct elf_link - /* Set the sizes of the dynamic sections. */ - - static bool --ppc64_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+ppc64_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct ppc_link_hash_table *htab; - bfd *dynobj; -@@ -10210,7 +10210,7 @@ ppc64_elf_size_dynamic_sections (bfd *ou - - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { ---- a/bfd/elf64-s390.c -+++ b/bfd/elf64-s390.c -@@ -1301,7 +1301,7 @@ elf_s390_gc_mark_hook (asection *sec, - entry but we found we will not create any. Called when we find we will - not have any PLT for this symbol, by for example - elf_s390_adjust_dynamic_symbol when we're doing a proper dynamic link, -- or elf_s390_size_dynamic_sections if no dynamic sections will be -+ or elf_s390_late_size_sections if no dynamic sections will be - created (we're only linking static objects). */ - - static void -@@ -1714,8 +1714,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_s390_link_hash_table *htab; - bfd *dynobj; -@@ -1729,7 +1729,7 @@ elf_s390_size_dynamic_sections (bfd *out - - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -3894,7 +3894,7 @@ const struct elf_size_info s390_elf64_si - #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook - #define elf_backend_reloc_type_class elf_s390_reloc_type_class - #define elf_backend_relocate_section elf_s390_relocate_section --#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections -+#define elf_backend_late_size_sections elf_s390_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_grok_prstatus elf_s390_grok_prstatus - #define elf_backend_grok_psinfo elf_s390_grok_psinfo ---- a/bfd/elf64-sparc.c -+++ b/bfd/elf64-sparc.c -@@ -938,8 +938,8 @@ const struct elf_size_info elf64_sparc_s - _bfd_sparc_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym \ - _bfd_sparc_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections \ -- _bfd_sparc_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_sparc_elf_late_size_sections - #define elf_backend_relocate_section \ - _bfd_sparc_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf64-tilegx.c -+++ b/bfd/elf64-tilegx.c -@@ -106,7 +106,7 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_I - #define elf_backend_check_relocs tilegx_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol tilegx_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym tilegx_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections tilegx_elf_size_dynamic_sections -+#define elf_backend_late_size_sections tilegx_elf_late_size_sections - #define elf_backend_relocate_section tilegx_elf_relocate_section - #define elf_backend_finish_dynamic_symbol tilegx_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections tilegx_elf_finish_dynamic_sections ---- a/bfd/elf64-x86-64.c -+++ b/bfd/elf64-x86-64.c -@@ -2377,8 +2377,7 @@ elf_x86_64_scan_relocs (bfd *abfd, struc - } - - static bool --elf_x86_64_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf_x86_64_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *abfd; - -@@ -2391,7 +2390,7 @@ elf_x86_64_always_size_sections (bfd *ou - elf_x86_64_scan_relocs)) - return false; - -- return _bfd_x86_elf_always_size_sections (output_bfd, info); -+ return _bfd_x86_elf_early_size_sections (output_bfd, info); - } - - /* Return the relocation value for @tpoff relocation -@@ -5284,7 +5283,7 @@ elf_x86_64_special_sections[]= - elf_x86_64_reloc_name_lookup - - #define elf_backend_relocs_compatible elf_x86_64_relocs_compatible --#define elf_backend_always_size_sections elf_x86_64_always_size_sections -+#define elf_backend_early_size_sections elf_x86_64_early_size_sections - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections elf_x86_64_finish_dynamic_sections - #define elf_backend_finish_dynamic_symbol elf_x86_64_finish_dynamic_symbol ---- a/bfd/elflink.c -+++ b/bfd/elflink.c -@@ -6619,8 +6619,8 @@ bfd_elf_size_dynamic_sections (bfd *outp - - /* The backend may have to create some sections regardless of whether - we're dynamic or not. */ -- if (bed->elf_backend_always_size_sections -- && ! (*bed->elf_backend_always_size_sections) (output_bfd, info)) -+ if (bed->elf_backend_early_size_sections -+ && !bed->elf_backend_early_size_sections (output_bfd, info)) - return false; - - dynobj = elf_hash_table (info)->dynobj; -@@ -7400,9 +7400,8 @@ NOTE: This behaviour is deprecated and w - - /* The backend must work out the sizes of all the other dynamic - sections. */ -- if (dynobj != NULL -- && bed->elf_backend_size_dynamic_sections != NULL -- && ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info)) -+ if (bed->elf_backend_late_size_sections != NULL -+ && !bed->elf_backend_late_size_sections (output_bfd, info)) - return false; - - if (dynobj != NULL && elf_hash_table (info)->dynamic_sections_created) ---- a/bfd/elfn32-mips.c -+++ b/bfd/elfn32-mips.c -@@ -4125,10 +4125,8 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_mips_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_mips_elf_size_dynamic_sections -+#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections -+#define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elfnn-aarch64.c -+++ b/bfd/elfnn-aarch64.c -@@ -112,7 +112,7 @@ - allocate space for one relocation on the slot. Record the GOT offset - for this symbol. - -- elfNN_aarch64_size_dynamic_sections () -+ elfNN_aarch64_late_size_sections () - - Iterate all input BFDS, look for in the local symbol data structure - constructed earlier for local TLS symbols and allocate them double -@@ -8886,8 +8886,8 @@ elfNN_aarch64_allocate_local_ifunc_dynre - though ! */ - - static bool --elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elfNN_aarch64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_aarch64_link_hash_table *htab; - bfd *dynobj; -@@ -8898,7 +8898,8 @@ elfNN_aarch64_size_dynamic_sections (bfd - htab = elf_aarch64_hash_table ((info)); - dynobj = htab->root.dynobj; - -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -9300,8 +9301,8 @@ elfNN_aarch64_create_small_pltn_entry (s - _TLS_MODULE_BASE_, if needed. */ - - static bool --elfNN_aarch64_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elfNN_aarch64_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - asection *tls_sec; - -@@ -10036,8 +10037,8 @@ const struct elf_size_info elfNN_aarch64 - #define elf_backend_adjust_dynamic_symbol \ - elfNN_aarch64_adjust_dynamic_symbol - --#define elf_backend_always_size_sections \ -- elfNN_aarch64_always_size_sections -+#define elf_backend_early_size_sections \ -+ elfNN_aarch64_early_size_sections - - #define elf_backend_check_relocs \ - elfNN_aarch64_check_relocs -@@ -10086,8 +10087,8 @@ const struct elf_size_info elfNN_aarch64 - #define elf_backend_section_from_shdr \ - elfNN_aarch64_section_from_shdr - --#define elf_backend_size_dynamic_sections \ -- elfNN_aarch64_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elfNN_aarch64_late_size_sections - - #define elf_backend_size_info \ - elfNN_aarch64_size_info ---- a/bfd/elfnn-ia64.c -+++ b/bfd/elfnn-ia64.c -@@ -2986,8 +2986,8 @@ elfNN_ia64_adjust_dynamic_symbol (struct - } - - static bool --elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elfNN_ia64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elfNN_ia64_allocate_data data; - struct elfNN_ia64_link_hash_table *ia64_info; -@@ -2998,8 +2998,9 @@ elfNN_ia64_size_dynamic_sections (bfd *o - if (ia64_info == NULL) - return false; - dynobj = ia64_info->root.dynobj; -+ if (dynobj == NULL) -+ return true; - ia64_info->self_dtpmod_offset = (bfd_vma) -1; -- BFD_ASSERT(dynobj != NULL); - data.info = info; - - /* Set the contents of the .interp section to the interpreter. */ -@@ -5035,8 +5036,8 @@ ignore_errors (const char *fmt ATTRIBUTE - elfNN_ia64_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - elfNN_ia64_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- elfNN_ia64_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elfNN_ia64_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_relocate_section \ ---- a/bfd/elfnn-loongarch.c -+++ b/bfd/elfnn-loongarch.c -@@ -1280,8 +1280,8 @@ maybe_set_textrel (struct elf_link_hash_ - } - - static bool --loongarch_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+loongarch_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct loongarch_elf_link_hash_table *htab; - bfd *dynobj; -@@ -1291,7 +1291,8 @@ loongarch_elf_size_dynamic_sections (bfd - htab = loongarch_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -3444,7 +3445,7 @@ elf_loongarch64_hash_symbol (struct elf_ - loongarch_elf_create_dynamic_sections - #define elf_backend_check_relocs loongarch_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol loongarch_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections loongarch_elf_size_dynamic_sections -+#define elf_backend_late_size_sections loongarch_elf_late_size_sections - #define elf_backend_relocate_section loongarch_elf_relocate_section - #define elf_backend_finish_dynamic_symbol loongarch_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections \ ---- a/bfd/elfnn-riscv.c -+++ b/bfd/elfnn-riscv.c -@@ -1376,7 +1376,7 @@ allocate_local_ifunc_dynrelocs (void **s - } - - static bool --riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+riscv_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct riscv_elf_link_hash_table *htab; - bfd *dynobj; -@@ -1386,7 +1386,8 @@ riscv_elf_size_dynamic_sections (bfd *ou - htab = riscv_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5256,7 +5257,7 @@ riscv_elf_merge_symbol_attribute (struct - #define elf_backend_create_dynamic_sections riscv_elf_create_dynamic_sections - #define elf_backend_check_relocs riscv_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol riscv_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections riscv_elf_size_dynamic_sections -+#define elf_backend_late_size_sections riscv_elf_late_size_sections - #define elf_backend_relocate_section riscv_elf_relocate_section - #define elf_backend_finish_dynamic_symbol riscv_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections riscv_elf_finish_dynamic_sections ---- a/bfd/elfxx-mips.c -+++ b/bfd/elfxx-mips.c -@@ -9559,8 +9559,8 @@ _bfd_mips_elf_adjust_dynamic_symbol (str - check for any mips16 stub sections that we can discard. */ - - bool --_bfd_mips_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_mips_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - asection *sect; - struct mips_elf_link_hash_table *htab; -@@ -9903,8 +9903,8 @@ mips_elf_set_plt_sym_value (struct mips_ - /* Set the sizes of the dynamic sections. */ - - bool --_bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_mips_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s, *sreldyn; -@@ -9914,7 +9914,8 @@ _bfd_mips_elf_size_dynamic_sections (bfd - htab = mips_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -14833,7 +14834,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_always_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_early_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf_External_ABIFlags_v0)); - - /* Skip this section later on (I don't think this currently -@@ -14892,7 +14893,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_always_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_early_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf32_External_RegInfo)); - - /* Skip this section later on (I don't think this currently ---- a/bfd/elfxx-mips.h -+++ b/bfd/elfxx-mips.h -@@ -52,9 +52,9 @@ extern bool _bfd_mips_elf_check_relocs - (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); - extern bool _bfd_mips_elf_adjust_dynamic_symbol - (struct bfd_link_info *, struct elf_link_hash_entry *); --extern bool _bfd_mips_elf_always_size_sections -+extern bool _bfd_mips_elf_early_size_sections - (bfd *, struct bfd_link_info *); --extern bool _bfd_mips_elf_size_dynamic_sections -+extern bool _bfd_mips_elf_late_size_sections - (bfd *, struct bfd_link_info *); - extern int _bfd_mips_elf_relocate_section - (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, ---- a/bfd/elfxx-sparc.c -+++ b/bfd/elfxx-sparc.c -@@ -2381,8 +2381,8 @@ _bfd_sparc_elf_omit_section_dynsym (bfd - /* Set the sizes of the dynamic sections. */ - - bool --_bfd_sparc_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_sparc_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct _bfd_sparc_elf_link_hash_table *htab; - bfd *dynobj; -@@ -2392,7 +2392,8 @@ _bfd_sparc_elf_size_dynamic_sections (bf - htab = _bfd_sparc_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { ---- a/bfd/elfxx-sparc.h -+++ b/bfd/elfxx-sparc.h -@@ -117,7 +117,7 @@ extern bool _bfd_sparc_elf_adjust_dynami - (struct bfd_link_info *, struct elf_link_hash_entry *); - extern bool _bfd_sparc_elf_omit_section_dynsym - (bfd *, struct bfd_link_info *, asection *); --extern bool _bfd_sparc_elf_size_dynamic_sections -+extern bool _bfd_sparc_elf_late_size_sections - (bfd *, struct bfd_link_info *); - extern bool _bfd_sparc_elf_new_section_hook - (bfd *, asection *); ---- a/bfd/elfxx-target.h -+++ b/bfd/elfxx-target.h -@@ -483,11 +483,11 @@ - #ifndef elf_backend_adjust_dynamic_symbol - #define elf_backend_adjust_dynamic_symbol 0 - #endif --#ifndef elf_backend_always_size_sections --#define elf_backend_always_size_sections 0 -+#ifndef elf_backend_early_size_sections -+#define elf_backend_early_size_sections 0 - #endif --#ifndef elf_backend_size_dynamic_sections --#define elf_backend_size_dynamic_sections 0 -+#ifndef elf_backend_late_size_sections -+#define elf_backend_late_size_sections 0 - #endif - #ifndef elf_backend_strip_zero_sized_dynamic_sections - #define elf_backend_strip_zero_sized_dynamic_sections 0 -@@ -842,8 +842,8 @@ static const struct elf_backend_data elf - elf_backend_check_directives, - elf_backend_notice_as_needed, - elf_backend_adjust_dynamic_symbol, -- elf_backend_always_size_sections, -- elf_backend_size_dynamic_sections, -+ elf_backend_early_size_sections, -+ elf_backend_late_size_sections, - elf_backend_strip_zero_sized_dynamic_sections, - elf_backend_init_index_section, - elf_backend_relocate_section, ---- a/bfd/elfxx-tilegx.c -+++ b/bfd/elfxx-tilegx.c -@@ -2430,8 +2430,8 @@ tilegx_elf_omit_section_dynsym (bfd *out - } - - bool --tilegx_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+tilegx_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct tilegx_elf_link_hash_table *htab; - bfd *dynobj; -@@ -2441,7 +2441,8 @@ tilegx_elf_size_dynamic_sections (bfd *o - htab = tilegx_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { ---- a/bfd/elfxx-tilegx.h -+++ b/bfd/elfxx-tilegx.h -@@ -57,7 +57,7 @@ tilegx_elf_omit_section_dynsym (bfd *, - asection *); - - extern bool --tilegx_elf_size_dynamic_sections (bfd *, struct bfd_link_info *); -+tilegx_elf_late_size_sections (bfd *, struct bfd_link_info *); - - extern int - tilegx_elf_relocate_section (bfd *, struct bfd_link_info *, ---- a/bfd/elfxx-x86.c -+++ b/bfd/elfxx-x86.c -@@ -2019,7 +2019,7 @@ _bfd_elf_x86_valid_reloc_p (asection *in - /* Set the sizes of the dynamic sections. */ - - bool --_bfd_x86_elf_size_dynamic_sections (bfd *output_bfd, -+_bfd_x86_elf_late_size_sections (bfd *output_bfd, - struct bfd_link_info *info) - { - struct elf_x86_link_hash_table *htab; -@@ -2035,7 +2035,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd - return false; - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - /* Set up .got offsets for local syms, and space for local dynamic - relocs. */ -@@ -2616,8 +2616,8 @@ _bfd_x86_elf_finish_dynamic_sections (bf - - - bool --_bfd_x86_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_x86_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - asection *tls_sec = elf_hash_table (info)->tls_sec; - ---- a/bfd/elfxx-x86.h -+++ b/bfd/elfxx-x86.h -@@ -807,13 +807,13 @@ extern bool _bfd_elf_x86_valid_reloc_p - const Elf_Internal_Rela *, struct elf_link_hash_entry *, - Elf_Internal_Sym *, Elf_Internal_Shdr *, bool *); - --extern bool _bfd_x86_elf_size_dynamic_sections -+extern bool _bfd_x86_elf_late_size_sections - (bfd *, struct bfd_link_info *); - - extern struct elf_x86_link_hash_table *_bfd_x86_elf_finish_dynamic_sections - (bfd *, struct bfd_link_info *); - --extern bool _bfd_x86_elf_always_size_sections -+extern bool _bfd_x86_elf_early_size_sections - (bfd *, struct bfd_link_info *); - - extern void _bfd_x86_elf_merge_symbol_attribute -@@ -885,8 +885,8 @@ extern void _bfd_x86_elf_link_report_rel - - #define elf_backend_check_relocs \ - _bfd_x86_elf_check_relocs --#define elf_backend_size_dynamic_sections \ -- _bfd_x86_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_x86_elf_late_size_sections - #define elf_backend_merge_symbol_attribute \ - _bfd_x86_elf_merge_symbol_attribute - #define elf_backend_copy_indirect_symbol \ ---- a/ld/emultempl/vms.em -+++ b/ld/emultempl/vms.em -@@ -196,10 +196,9 @@ gld${EMULATION_NAME}_before_allocation ( - - /* The backend must work out the sizes of all the other dynamic - sections. */ -- if (elf_hash_table (&link_info)->dynamic_sections_created -- && bed->elf_backend_size_dynamic_sections -- && ! (*bed->elf_backend_size_dynamic_sections) (link_info.output_bfd, -- &link_info)) -+ if (bed->elf_backend_late_size_sections -+ && !bed->elf_backend_late_size_sections (link_info.output_bfd, -+ &link_info)) - einfo (_("%F%P: failed to set dynamic section sizes: %E\n")); - - before_allocation_default (); diff --git a/toolchain/binutils/patches/2.39/002-PR-30569-delete-_bfd_mips_elf_early_size_sections.patch b/toolchain/binutils/patches/2.39/002-PR-30569-delete-_bfd_mips_elf_early_size_sections.patch deleted file mode 100644 index f0c0d7a10a..0000000000 --- a/toolchain/binutils/patches/2.39/002-PR-30569-delete-_bfd_mips_elf_early_size_sections.patch +++ /dev/null @@ -1,218 +0,0 @@ -From 3c6c32951e292a51ede70b8087bb0308d7dbc4fc Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Thu, 28 Mar 2024 20:33:32 +1030 -Subject: [PATCH 2/2] PR 30569, delete _bfd_mips_elf_early_size_sections - -PR30569 was triggered by a patch of mine 6540edd52cc0 moving the call -to always_size_sections in bfd_elf_size_dynamic_sections earlier, made -to support the x86 DT_RELR implementation. This broke mips16 code -handling stubs when --export-dynamic is passed to the linker, because -numerous symbols then became dynamic after always_size_sections. The -mips backend fiddles with symbols in its always_size_sections. Maciej -in 902e9fc76a0e had moved the call to always_size_sections to after -the export-dynamic code. Prior to that, Nathan in 04c3a75556c0 moved -it before the exec stack code, back to the start of -bfd_elf_size_dynamic_sections which was where Ian put it originally -in ff12f303355b. So the call has moved around a little. I'm leaving -it where it is, and instead calling mips_elf_check_symbols from -late_size_sections (the old size_dynamic_sections) which is now always -called. In fact, the whole of _bfd_mips_elf_early_size_sections can -be merged into _bfd_mips_elf_late_size_sections. ---- - bfd/elf32-mips.c | 1 - - bfd/elf64-mips.c | 2 -- - bfd/elfn32-mips.c | 1 - - bfd/elfxx-mips.c | 84 +++++++++++++++++++---------------------------- - bfd/elfxx-mips.h | 2 -- - 5 files changed, 34 insertions(+), 56 deletions(-) - ---- a/bfd/elf32-mips.c -+++ b/bfd/elf32-mips.c -@@ -2525,7 +2525,6 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections - #define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section ---- a/bfd/elf64-mips.c -+++ b/bfd/elf64-mips.c -@@ -4739,8 +4739,6 @@ const struct elf_size_info mips_elf64_si - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_early_size_sections \ -- _bfd_mips_elf_early_size_sections - #define elf_backend_late_size_sections \ - _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section ---- a/bfd/elfn32-mips.c -+++ b/bfd/elfn32-mips.c -@@ -4125,7 +4125,6 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections - #define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section ---- a/bfd/elfxx-mips.c -+++ b/bfd/elfxx-mips.c -@@ -9554,48 +9554,6 @@ _bfd_mips_elf_adjust_dynamic_symbol (str - return _bfd_elf_adjust_dynamic_copy (info, h, s); - } - --/* This function is called after all the input files have been read, -- and the input sections have been assigned to output sections. We -- check for any mips16 stub sections that we can discard. */ -- --bool --_bfd_mips_elf_early_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) --{ -- asection *sect; -- struct mips_elf_link_hash_table *htab; -- struct mips_htab_traverse_info hti; -- -- htab = mips_elf_hash_table (info); -- BFD_ASSERT (htab != NULL); -- -- /* The .reginfo section has a fixed size. */ -- sect = bfd_get_section_by_name (output_bfd, ".reginfo"); -- if (sect != NULL) -- { -- bfd_set_section_size (sect, sizeof (Elf32_External_RegInfo)); -- sect->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -- } -- -- /* The .MIPS.abiflags section has a fixed size. */ -- sect = bfd_get_section_by_name (output_bfd, ".MIPS.abiflags"); -- if (sect != NULL) -- { -- bfd_set_section_size (sect, sizeof (Elf_External_ABIFlags_v0)); -- sect->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -- } -- -- hti.info = info; -- hti.output_bfd = output_bfd; -- hti.error = false; -- mips_elf_link_hash_traverse (mips_elf_hash_table (info), -- mips_elf_check_symbols, &hti); -- if (hti.error) -- return false; -- -- return true; --} -- - /* If the link uses a GOT, lay it out and work out its size. */ - - static bool -@@ -9900,7 +9858,8 @@ mips_elf_set_plt_sym_value (struct mips_ - return true; - } - --/* Set the sizes of the dynamic sections. */ -+/* Set the sizes of the dynamic sections, some mips non-dynamic sections, -+ and check for any mips16 stub sections that we can discard. */ - - bool - _bfd_mips_elf_late_size_sections (bfd *output_bfd, -@@ -9910,14 +9869,39 @@ _bfd_mips_elf_late_size_sections (bfd *o - asection *s, *sreldyn; - bool reltext; - struct mips_elf_link_hash_table *htab; -+ struct mips_htab_traverse_info hti; - - htab = mips_elf_hash_table (info); - BFD_ASSERT (htab != NULL); -- dynobj = elf_hash_table (info)->dynobj; -+ -+ /* The .reginfo section has a fixed size. */ -+ s = bfd_get_section_by_name (output_bfd, ".reginfo"); -+ if (s != NULL) -+ { -+ bfd_set_section_size (s, sizeof (Elf32_External_RegInfo)); -+ s->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -+ } -+ -+ /* The .MIPS.abiflags section has a fixed size. */ -+ s = bfd_get_section_by_name (output_bfd, ".MIPS.abiflags"); -+ if (s != NULL) -+ { -+ bfd_set_section_size (s, sizeof (Elf_External_ABIFlags_v0)); -+ s->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -+ } -+ -+ hti.info = info; -+ hti.output_bfd = output_bfd; -+ hti.error = false; -+ mips_elf_link_hash_traverse (htab, mips_elf_check_symbols, &hti); -+ if (hti.error) -+ return false; -+ -+ dynobj = htab->root.dynobj; - if (dynobj == NULL) - return true; - -- if (elf_hash_table (info)->dynamic_sections_created) -+ if (htab->root.dynamic_sections_created) - { - /* Set the contents of the .interp section to the interpreter. */ - if (bfd_link_executable (info) && !info->nointerp) -@@ -10057,7 +10041,7 @@ _bfd_mips_elf_late_size_sections (bfd *o - } - } - else if (bfd_link_executable (info) -- && ! mips_elf_hash_table (info)->use_rld_obj_head -+ && !htab->use_rld_obj_head - && startswith (name, ".rld_map")) - { - /* We add a room for __rld_map. It will be filled in by the -@@ -10066,7 +10050,7 @@ _bfd_mips_elf_late_size_sections (bfd *o - } - else if (SGI_COMPAT (output_bfd) - && startswith (name, ".compact_rel")) -- s->size += mips_elf_hash_table (info)->compact_rel_size; -+ s->size += htab->compact_rel_size; - else if (s == htab->root.splt) - { - /* If the last PLT entry has a branch delay slot, allocate -@@ -10106,7 +10090,7 @@ _bfd_mips_elf_late_size_sections (bfd *o - } - } - -- if (elf_hash_table (info)->dynamic_sections_created) -+ if (htab->root.dynamic_sections_created) - { - /* Add some entries to the .dynamic section. We fill in the - values later, in _bfd_mips_elf_finish_dynamic_sections, but we -@@ -14834,7 +14818,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_early_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_late_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf_External_ABIFlags_v0)); - - /* Skip this section later on (I don't think this currently -@@ -14893,7 +14877,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_early_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_late_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf32_External_RegInfo)); - - /* Skip this section later on (I don't think this currently ---- a/bfd/elfxx-mips.h -+++ b/bfd/elfxx-mips.h -@@ -52,8 +52,6 @@ extern bool _bfd_mips_elf_check_relocs - (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); - extern bool _bfd_mips_elf_adjust_dynamic_symbol - (struct bfd_link_info *, struct elf_link_hash_entry *); --extern bool _bfd_mips_elf_early_size_sections -- (bfd *, struct bfd_link_info *); - extern bool _bfd_mips_elf_late_size_sections - (bfd *, struct bfd_link_info *); - extern int _bfd_mips_elf_relocate_section diff --git a/toolchain/binutils/patches/2.39/005-ld-fix-NEWS-typos.patch b/toolchain/binutils/patches/2.39/005-ld-fix-NEWS-typos.patch deleted file mode 100644 index 39c61d9319..0000000000 --- a/toolchain/binutils/patches/2.39/005-ld-fix-NEWS-typos.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 9284b63ea39cecbfc1522d9e143ecb7727d77eb5 Mon Sep 17 00:00:00 2001 -From: Martin Liska -Date: Mon, 8 Aug 2022 13:22:26 +0200 -Subject: [PATCH 005/160] ld: fix NEWS typos - -ld/ChangeLog: - - * NEWS: Fix 2 typos. ---- - ld/NEWS | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/ld/NEWS -+++ b/ld/NEWS -@@ -27,10 +27,10 @@ Changes in 2.39: - --enable-warn-rwx-segments=no - will make --no-warn-rwx-segments enabled by default. - -- --enable-defaul-execstack=no -+ --enable-default-execstack=no - will stop the creation of an executable stack simply because an input file - is missing a .note.GNU-stack section, even on architectures where this -- ehaviour is the default. -+ behaviour is the default. - - * TYPE= is now supported in an output section description to set the - section type value. diff --git a/toolchain/binutils/patches/2.39/008-gas-Dwarf-properly-skip-zero-size-functions.patch b/toolchain/binutils/patches/2.39/008-gas-Dwarf-properly-skip-zero-size-functions.patch deleted file mode 100644 index 055da84129..0000000000 --- a/toolchain/binutils/patches/2.39/008-gas-Dwarf-properly-skip-zero-size-functions.patch +++ /dev/null @@ -1,90 +0,0 @@ -From e8cf73215187b0c08679d726a5cc7c019fa3ea2e Mon Sep 17 00:00:00 2001 -From: Jan Beulich -Date: Wed, 10 Aug 2022 10:34:22 +0200 -Subject: [PATCH 008/160] gas/Dwarf: properly skip zero-size functions - -PR gas/29451 - -While out_debug_abbrev() properly skips such functions, out_debug_info() -mistakenly didn't. It needs to calculate the high_pc expression ahead of -time, in order to skip emitting any data for the function if the value -is zero. - -The one case which would still leave a zero-size entry is when -symbol_get_obj(symp)->size ends up evaluating to zero. I hope we can -expect that to not be the case, otherwise we'd need to have a way to -post-process .debug_info contents between resolving expressions and -actually writing the data out to the file. Even then it wouldn't be -entirely obvious in which way to alter the data. - -(cherry picked from commit d7abcbcea5ddd40a3bf28758b62f35933c59f996) ---- - gas/dwarf2dbg.c | 39 ++++++++++++++++++++------------------- - 1 file changed, 20 insertions(+), 19 deletions(-) - ---- a/gas/dwarf2dbg.c -+++ b/gas/dwarf2dbg.c -@@ -2882,6 +2882,7 @@ out_debug_info (segT info_seg, segT abbr - { - const char *name; - size_t len; -+ expressionS size = { .X_op = O_constant }; - - /* Skip warning constructs (see above). */ - if (symbol_get_bfdsym (symp)->flags & BSF_WARNING) -@@ -2895,6 +2896,18 @@ out_debug_info (segT info_seg, segT abbr - if (!S_IS_DEFINED (symp) || !S_IS_FUNCTION (symp)) - continue; - -+#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */ -+ size.X_add_number = S_GET_SIZE (symp); -+ if (size.X_add_number == 0 && IS_ELF -+ && symbol_get_obj (symp)->size != NULL) -+ { -+ size.X_op = O_add; -+ size.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size); -+ } -+#endif -+ if (size.X_op == O_constant && size.X_add_number == 0) -+ continue; -+ - subseg_set (str_seg, 0); - name_sym = symbol_temp_new_now_octets (); - name = S_GET_NAME (symp); -@@ -2920,29 +2933,17 @@ out_debug_info (segT info_seg, segT abbr - emit_expr (&exp, sizeof_address); - - /* DW_AT_high_pc */ -- exp.X_op = O_constant; --#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */ -- exp.X_add_number = S_GET_SIZE (symp); -- if (exp.X_add_number == 0 && IS_ELF -- && symbol_get_obj (symp)->size != NULL) -- { -- exp.X_op = O_add; -- exp.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size); -- } --#else -- exp.X_add_number = 0; --#endif - if (DWARF2_VERSION < 4) - { -- if (exp.X_op == O_constant) -- exp.X_op = O_symbol; -- exp.X_add_symbol = symp; -- emit_expr (&exp, sizeof_address); -+ if (size.X_op == O_constant) -+ size.X_op = O_symbol; -+ size.X_add_symbol = symp; -+ emit_expr (&size, sizeof_address); - } -- else if (exp.X_op == O_constant) -- out_uleb128 (exp.X_add_number); -+ else if (size.X_op == O_constant) -+ out_uleb128 (size.X_add_number); - else -- emit_leb128_expr (symbol_get_value_expression (exp.X_op_symbol), 0); -+ emit_leb128_expr (symbol_get_value_expression (size.X_op_symbol), 0); - } - - /* End of children. */ diff --git a/toolchain/binutils/patches/2.39/009-PR29462-internal-error-in-relocate-at-powerpc.cc-107.patch b/toolchain/binutils/patches/2.39/009-PR29462-internal-error-in-relocate-at-powerpc.cc-107.patch deleted file mode 100644 index e325d3bcb0..0000000000 --- a/toolchain/binutils/patches/2.39/009-PR29462-internal-error-in-relocate-at-powerpc.cc-107.patch +++ /dev/null @@ -1,270 +0,0 @@ -From e3b5d935247084dca057dea72be61b063fe2357a Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Wed, 10 Aug 2022 10:38:52 +0930 -Subject: [PATCH 009/160] PR29462, internal error in relocate, at - powerpc.cc:10796 - -Prior to the inline plt call support (commit 08be322439), the only -local syms with plt entries were local ifunc symbols. There shouldn't -be stubs for other local symbols so don't look for them. The patch -also fixes minor bugs in get_reference_flags; Many relocs are valid -only for ppc64 and a couple only for ppc32. - - PR 29462 - * powerpc.cc (Target_powerpc::Relocate::relocate): Rename - use_plt_offset to pltcal_to_direct, invert logic. For relocs - not used with inline plt sequences against local symbols, only - look for stubs when the symbol is an ifunc. - (Target_powerpc::Scan::get_reference_flags): Correct reloc - handling for relocs not valid for both 32-bit and 64-bit. - -(cherry picked from commit 6158b25f77db11712b84e6a4609898f2615ac749) ---- - gold/powerpc.cc | 129 ++++++++++++++++++++++++++++-------------------- - 1 file changed, 75 insertions(+), 54 deletions(-) - ---- a/gold/powerpc.cc -+++ b/gold/powerpc.cc -@@ -7675,22 +7675,18 @@ Target_powerpc::Scan:: - - switch (r_type) - { -+ case elfcpp::R_PPC64_TOC: -+ if (size != 64) -+ break; -+ // Fall through. - case elfcpp::R_POWERPC_NONE: - case elfcpp::R_POWERPC_GNU_VTINHERIT: - case elfcpp::R_POWERPC_GNU_VTENTRY: -- case elfcpp::R_PPC64_TOC: - // No symbol reference. - break; - - case elfcpp::R_PPC64_ADDR64: - case elfcpp::R_PPC64_UADDR64: -- case elfcpp::R_POWERPC_ADDR32: -- case elfcpp::R_POWERPC_UADDR32: -- case elfcpp::R_POWERPC_ADDR16: -- case elfcpp::R_POWERPC_UADDR16: -- case elfcpp::R_POWERPC_ADDR16_LO: -- case elfcpp::R_POWERPC_ADDR16_HI: -- case elfcpp::R_POWERPC_ADDR16_HA: - case elfcpp::R_PPC64_ADDR16_HIGHER34: - case elfcpp::R_PPC64_ADDR16_HIGHERA34: - case elfcpp::R_PPC64_ADDR16_HIGHEST34: -@@ -7700,6 +7696,16 @@ Target_powerpc::Scan:: - case elfcpp::R_PPC64_D34_HI30: - case elfcpp::R_PPC64_D34_HA30: - case elfcpp::R_PPC64_D28: -+ if (size != 64) -+ break; -+ // Fall through. -+ case elfcpp::R_POWERPC_ADDR32: -+ case elfcpp::R_POWERPC_UADDR32: -+ case elfcpp::R_POWERPC_ADDR16: -+ case elfcpp::R_POWERPC_UADDR16: -+ case elfcpp::R_POWERPC_ADDR16_LO: -+ case elfcpp::R_POWERPC_ADDR16_HI: -+ case elfcpp::R_POWERPC_ADDR16_HA: - ref = Symbol::ABSOLUTE_REF; - break; - -@@ -7710,13 +7716,14 @@ Target_powerpc::Scan:: - ref = Symbol::FUNCTION_CALL | Symbol::ABSOLUTE_REF; - break; - -- case elfcpp::R_PPC64_REL64: -- case elfcpp::R_POWERPC_REL32: - case elfcpp::R_PPC_LOCAL24PC: -- case elfcpp::R_POWERPC_REL16: -- case elfcpp::R_POWERPC_REL16_LO: -- case elfcpp::R_POWERPC_REL16_HI: -- case elfcpp::R_POWERPC_REL16_HA: -+ if (size != 32) -+ break; -+ // Fall through. -+ ref = Symbol::RELATIVE_REF; -+ break; -+ -+ case elfcpp::R_PPC64_REL64: - case elfcpp::R_PPC64_REL16_HIGH: - case elfcpp::R_PPC64_REL16_HIGHA: - case elfcpp::R_PPC64_REL16_HIGHER: -@@ -7729,36 +7736,45 @@ Target_powerpc::Scan:: - case elfcpp::R_PPC64_REL16_HIGHEST34: - case elfcpp::R_PPC64_REL16_HIGHESTA34: - case elfcpp::R_PPC64_PCREL28: -+ if (size != 64) -+ break; -+ // Fall through. -+ case elfcpp::R_POWERPC_REL32: -+ case elfcpp::R_POWERPC_REL16: -+ case elfcpp::R_POWERPC_REL16_LO: -+ case elfcpp::R_POWERPC_REL16_HI: -+ case elfcpp::R_POWERPC_REL16_HA: - ref = Symbol::RELATIVE_REF; - break; - -+ case elfcpp::R_PPC_PLTREL24: -+ if (size != 32) -+ break; -+ ref = Symbol::FUNCTION_CALL | Symbol::RELATIVE_REF; -+ break; -+ - case elfcpp::R_PPC64_REL24_NOTOC: -- if (size == 32) -+ case elfcpp::R_PPC64_REL24_P9NOTOC: -+ case elfcpp::R_PPC64_PLT16_LO_DS: -+ case elfcpp::R_PPC64_PLTSEQ_NOTOC: -+ case elfcpp::R_PPC64_PLTCALL_NOTOC: -+ case elfcpp::R_PPC64_PLT_PCREL34: -+ case elfcpp::R_PPC64_PLT_PCREL34_NOTOC: -+ if (size != 64) - break; - // Fall through. -- case elfcpp::R_PPC64_REL24_P9NOTOC: - case elfcpp::R_POWERPC_REL24: -- case elfcpp::R_PPC_PLTREL24: - case elfcpp::R_POWERPC_REL14: - case elfcpp::R_POWERPC_REL14_BRTAKEN: - case elfcpp::R_POWERPC_REL14_BRNTAKEN: - case elfcpp::R_POWERPC_PLT16_LO: - case elfcpp::R_POWERPC_PLT16_HI: - case elfcpp::R_POWERPC_PLT16_HA: -- case elfcpp::R_PPC64_PLT16_LO_DS: - case elfcpp::R_POWERPC_PLTSEQ: -- case elfcpp::R_PPC64_PLTSEQ_NOTOC: - case elfcpp::R_POWERPC_PLTCALL: -- case elfcpp::R_PPC64_PLTCALL_NOTOC: -- case elfcpp::R_PPC64_PLT_PCREL34: -- case elfcpp::R_PPC64_PLT_PCREL34_NOTOC: - ref = Symbol::FUNCTION_CALL | Symbol::RELATIVE_REF; - break; - -- case elfcpp::R_POWERPC_GOT16: -- case elfcpp::R_POWERPC_GOT16_LO: -- case elfcpp::R_POWERPC_GOT16_HI: -- case elfcpp::R_POWERPC_GOT16_HA: - case elfcpp::R_PPC64_GOT16_DS: - case elfcpp::R_PPC64_GOT16_LO_DS: - case elfcpp::R_PPC64_GOT_PCREL34: -@@ -7768,11 +7784,16 @@ Target_powerpc::Scan:: - case elfcpp::R_PPC64_TOC16_HA: - case elfcpp::R_PPC64_TOC16_DS: - case elfcpp::R_PPC64_TOC16_LO_DS: -+ if (size != 64) -+ break; -+ // Fall through. -+ case elfcpp::R_POWERPC_GOT16: -+ case elfcpp::R_POWERPC_GOT16_LO: -+ case elfcpp::R_POWERPC_GOT16_HI: -+ case elfcpp::R_POWERPC_GOT16_HA: - ref = Symbol::RELATIVE_REF; - break; - -- case elfcpp::R_POWERPC_GOT_TPREL16: -- case elfcpp::R_POWERPC_TLS: - case elfcpp::R_PPC64_TLSGD: - case elfcpp::R_PPC64_TLSLD: - case elfcpp::R_PPC64_TPREL34: -@@ -7781,6 +7802,11 @@ Target_powerpc::Scan:: - case elfcpp::R_PPC64_GOT_TLSLD_PCREL34: - case elfcpp::R_PPC64_GOT_TPREL_PCREL34: - case elfcpp::R_PPC64_GOT_DTPREL_PCREL34: -+ if (size != 64) -+ break; -+ // Fall through. -+ case elfcpp::R_POWERPC_GOT_TPREL16: -+ case elfcpp::R_POWERPC_TLS: - ref = Symbol::TLS_REF; - break; - -@@ -10671,10 +10697,8 @@ Target_powerpc::Reloca - bool has_stub_value = false; - bool localentry0 = false; - unsigned int r_sym = elfcpp::elf_r_sym(rela.get_r_info()); -- bool use_plt_offset -- = (gsym != NULL -- ? gsym->use_plt_offset(Scan::get_reference_flags(r_type, target)) -- : object->local_has_plt_offset(r_sym)); -+ bool pltcall_to_direct = false; -+ - if (is_plt16_reloc(r_type) - || r_type == elfcpp::R_PPC64_PLT_PCREL34 - || r_type == elfcpp::R_PPC64_PLT_PCREL34_NOTOC -@@ -10688,21 +10712,18 @@ Target_powerpc::Reloca - // that the decision depends on the PLTCALL reloc, and we don't - // know the address of that instruction when processing others - // in the sequence. So the decision needs to be made in -- // do_relax(). For now, don't optimise inline plt calls. -- if (gsym) -- use_plt_offset = gsym->has_plt_offset(); -- } -- if (use_plt_offset -- && !is_got_reloc(r_type) -- && !is_plt16_reloc(r_type) -- && r_type != elfcpp::R_PPC64_PLT_PCREL34 -- && r_type != elfcpp::R_PPC64_PLT_PCREL34_NOTOC -- && r_type != elfcpp::R_POWERPC_PLTSEQ -- && r_type != elfcpp::R_POWERPC_PLTCALL -- && r_type != elfcpp::R_PPC64_PLTSEQ_NOTOC -- && r_type != elfcpp::R_PPC64_PLTCALL_NOTOC -- && (!psymval->is_ifunc_symbol() -- || Scan::reloc_needs_plt_for_ifunc(target, object, r_type, false))) -+ // do_relax(). -+ pltcall_to_direct = !(gsym != NULL -+ ? gsym->has_plt_offset() -+ : object->local_has_plt_offset(r_sym)); -+ } -+ else if ((gsym != NULL -+ ? gsym->use_plt_offset(Scan::get_reference_flags(r_type, target)) -+ : psymval->is_ifunc_symbol() && object->local_has_plt_offset(r_sym)) -+ && !is_got_reloc(r_type) -+ && (!psymval->is_ifunc_symbol() -+ || Scan::reloc_needs_plt_for_ifunc(target, object, r_type, -+ false))) - { - if (size == 64 - && gsym != NULL -@@ -10796,9 +10817,9 @@ Target_powerpc::Reloca - gold_assert(has_stub_value || !(os->flags() & elfcpp::SHF_ALLOC)); - } - -- if (use_plt_offset && (is_plt16_reloc(r_type) -- || r_type == elfcpp::R_PPC64_PLT_PCREL34 -- || r_type == elfcpp::R_PPC64_PLT_PCREL34_NOTOC)) -+ if (!pltcall_to_direct && (is_plt16_reloc(r_type) -+ || r_type == elfcpp::R_PPC64_PLT_PCREL34 -+ || r_type == elfcpp::R_PPC64_PLT_PCREL34_NOTOC)) - { - const Output_data_plt_powerpc* plt; - if (gsym) -@@ -10826,7 +10847,7 @@ Target_powerpc::Reloca - value -= target->toc_pointer(); - } - } -- else if (!use_plt_offset -+ else if (pltcall_to_direct - && (is_plt16_reloc(r_type) - || r_type == elfcpp::R_POWERPC_PLTSEQ - || r_type == elfcpp::R_PPC64_PLTSEQ_NOTOC)) -@@ -10835,7 +10856,7 @@ Target_powerpc::Reloca - elfcpp::Swap<32, big_endian>::writeval(iview, nop); - r_type = elfcpp::R_POWERPC_NONE; - } -- else if (!use_plt_offset -+ else if (pltcall_to_direct - && (r_type == elfcpp::R_PPC64_PLT_PCREL34 - || r_type == elfcpp::R_PPC64_PLT_PCREL34_NOTOC)) - { -@@ -11316,8 +11337,8 @@ Target_powerpc::Reloca - } - else if (!has_stub_value) - { -- if (!use_plt_offset && (r_type == elfcpp::R_POWERPC_PLTCALL -- || r_type == elfcpp::R_PPC64_PLTCALL_NOTOC)) -+ if (pltcall_to_direct && (r_type == elfcpp::R_POWERPC_PLTCALL -+ || r_type == elfcpp::R_PPC64_PLTCALL_NOTOC)) - { - // PLTCALL without plt entry => convert to direct call - Insn* iview = reinterpret_cast(view); diff --git a/toolchain/binutils/patches/2.39/011-PR29466-APP-NO_APP-with-.linefile.patch b/toolchain/binutils/patches/2.39/011-PR29466-APP-NO_APP-with-.linefile.patch deleted file mode 100644 index f7b5819929..0000000000 --- a/toolchain/binutils/patches/2.39/011-PR29466-APP-NO_APP-with-.linefile.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 9e855cffa1fda44629e7f9b76dfa3e5a51a440e9 Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Thu, 11 Aug 2022 09:51:03 +0930 -Subject: [PATCH 011/160] PR29466, APP/NO_APP with .linefile - -Commit 53f2b36a54b9 exposed a bug in sb_scrub_and_add_sb that could -result in losing input. If scrubbing results in expansion past the -holding capacity of do_scrub_chars output buffer, then do_scrub_chars -stashes the extra input for the next call. That call never came -because sb_scrub_and_add_sb wrongly decided it was done. Fix that by -allowing sb_scrub_and_add_sb to see whether there is pending input. -Also allow a little extra space so that in most cases we won't need -to resize the output buffer. - -sb_scrub_and_add_sb also limited output to the size of the input, -rather than the actual output buffer size. Fixing that resulted in a -fail of gas/testsuite/macros/dot with an extra warning: "end of file -not at end of a line; newline inserted". OK, so the macro in dot.s -really does finish without end-of-line. Apparently the macro -expansion code relied on do_scrub_chars returning early. So fix that -too by adding a newline if needed in macro_expand_body. - - PR 29466 - * app.c (do_scrub_pending): New function. - * as.h: Declare it. - * input-scrub.c (input_scrub_include_sb): Add extra space for - two .linefile directives. - * sb.c (sb_scrub_and_add_sb): Take into account pending input. - Allow output to max. - * macro.c (macro_expand_body): Add terminating newline. - * testsuite/config/default.exp (SIZE, SIZEFLAGS): Define. - * testsuite/gas/macros/app5.d, - * testsuite/gas/macros/app5.s: New test. - * testsuite/gas/macros/macros.exp: Run it. - -(cherry picked from commit 4d74aab7aa562fe79d4669cdad0c32610531cbc0) ---- - gas/app.c | 13 +++++++++++++ - gas/as.h | 1 + - gas/input-scrub.c | 6 ++++-- - gas/macro.c | 2 ++ - gas/sb.c | 5 +++-- - gas/testsuite/config/default.exp | 8 ++++++++ - gas/testsuite/gas/macros/app5.d | 6 ++++++ - gas/testsuite/gas/macros/app5.s | 5 +++++ - gas/testsuite/gas/macros/macros.exp | 1 + - 9 files changed, 43 insertions(+), 4 deletions(-) - create mode 100644 gas/testsuite/gas/macros/app5.d - create mode 100644 gas/testsuite/gas/macros/app5.s - ---- a/gas/app.c -+++ b/gas/app.c -@@ -1537,3 +1537,16 @@ do_scrub_chars (size_t (*get) (char *, s - last_char = to[-1]; - return to - tostart; - } -+ -+/* Return amount of pending input. */ -+ -+size_t -+do_scrub_pending (void) -+{ -+ size_t len = 0; -+ if (saved_input) -+ len += saved_input_len; -+ if (state == -1) -+ len += strlen (out_string); -+ return len; -+} ---- a/gas/as.h -+++ b/gas/as.h -@@ -460,6 +460,7 @@ void input_scrub_insert_file (char *); - char * input_scrub_new_file (const char *); - char * input_scrub_next_buffer (char **bufp); - size_t do_scrub_chars (size_t (*get) (char *, size_t), char *, size_t); -+size_t do_scrub_pending (void); - bool scan_for_multibyte_characters (const unsigned char *, const unsigned char *, bool); - int gen_to_words (LITTLENUM_TYPE *, int, long); - int had_err (void); ---- a/gas/input-scrub.c -+++ b/gas/input-scrub.c -@@ -278,9 +278,11 @@ input_scrub_include_sb (sb *from, char * - - next_saved_file = input_scrub_push (position); - -- /* Allocate sufficient space: from->len + optional newline. */ -+ /* Allocate sufficient space: from->len plus optional newline -+ plus two ".linefile " directives, plus a little more for other -+ expansion. */ - newline = from->len >= 1 && from->ptr[0] != '\n'; -- sb_build (&from_sb, from->len + newline); -+ sb_build (&from_sb, from->len + newline + 2 * sizeof (".linefile") + 30); - if (expansion == expanding_repeat && from_sb_expansion >= expanding_macro) - expansion = expanding_nested; - from_sb_expansion = expansion; ---- a/gas/macro.c -+++ b/gas/macro.c -@@ -1056,6 +1056,8 @@ macro_expand_body (sb *in, sb *out, form - loclist = f; - } - -+ if (!err && (out->len == 0 || out->ptr[out->len - 1] != '\n')) -+ sb_add_char (out, '\n'); - return err; - } - ---- a/gas/sb.c -+++ b/gas/sb.c -@@ -119,11 +119,12 @@ sb_scrub_and_add_sb (sb *ptr, sb *s) - So we loop until the input S is consumed. */ - while (1) - { -- size_t copy = s->len - (scrub_position - s->ptr); -+ size_t copy = s->len - (scrub_position - s->ptr) + do_scrub_pending (); - if (copy == 0) - break; - sb_check (ptr, copy); -- ptr->len += do_scrub_chars (scrub_from_sb, ptr->ptr + ptr->len, copy); -+ ptr->len += do_scrub_chars (scrub_from_sb, ptr->ptr + ptr->len, -+ ptr->max - ptr->len); - } - - sb_to_scrub = 0; ---- a/gas/testsuite/config/default.exp -+++ b/gas/testsuite/config/default.exp -@@ -52,6 +52,14 @@ if ![info exists NMFLAGS] then { - set NMFLAGS {} - } - -+if ![info exists SIZE] then { -+ set SIZE [findfile $base_dir/size] -+} -+ -+if ![info exists SIZEFLAGS] then { -+ set SIZEFLAGS "" -+} -+ - if ![info exists OBJCOPY] then { - set OBJCOPY [findfile $base_dir/../../binutils/objcopy] - } ---- /dev/null -+++ b/gas/testsuite/gas/macros/app5.d -@@ -0,0 +1,6 @@ -+#name: APP with linefile -+#xfail: tic30-*-* -+#size: -G -+# pr29466 just check that the test assembles -+ -+#pass ---- /dev/null -+++ b/gas/testsuite/gas/macros/app5.s -@@ -0,0 +1,5 @@ -+#NO_APP -+#APP -+# 5 "foo.c" 1 -+# 0 "" 2 -+#NO_APP ---- a/gas/testsuite/gas/macros/macros.exp -+++ b/gas/testsuite/gas/macros/macros.exp -@@ -70,6 +70,7 @@ run_dump_test app2 - run_dump_test app3 - remote_download host "$srcdir/$subdir/app4b.s" - run_dump_test app4 -+run_dump_test app5 - - run_list_test badarg "" - diff --git a/toolchain/binutils/patches/2.39/039-LoongArch-ld-Fix-relocation-error-of-pcrel.patch b/toolchain/binutils/patches/2.39/039-LoongArch-ld-Fix-relocation-error-of-pcrel.patch deleted file mode 100644 index bf452e566a..0000000000 --- a/toolchain/binutils/patches/2.39/039-LoongArch-ld-Fix-relocation-error-of-pcrel.patch +++ /dev/null @@ -1,128 +0,0 @@ -From 509a2ec6ad3ea7eb3f4cf59538cf636a2126e4c3 Mon Sep 17 00:00:00 2001 -From: liuzhensong -Date: Fri, 2 Sep 2022 16:29:14 +0800 -Subject: [PATCH 039/160] LoongArch:ld: Fix relocation error of pcrel. - - Patch for branch 2.39. - Need to reduce the address of pc when using - reloction R_LARCH_SOP_PUSH_PCREL. - - bfd/ - * elfnn-loongarch.c ---- - bfd/elfnn-loongarch.c | 3 +- - ld/testsuite/ld-loongarch-elf/pcrel-const.d | 14 +++++++ - ld/testsuite/ld-loongarch-elf/pcrel-const.lds | 14 +++++++ - ld/testsuite/ld-loongarch-elf/pcrel-const.s | 12 ++++++ - ld/testsuite/ld-loongarch-elf/pr.exp | 39 +++++++++++++++++++ - 5 files changed, 81 insertions(+), 1 deletion(-) - create mode 100644 ld/testsuite/ld-loongarch-elf/pcrel-const.d - create mode 100644 ld/testsuite/ld-loongarch-elf/pcrel-const.lds - create mode 100644 ld/testsuite/ld-loongarch-elf/pcrel-const.s - create mode 100644 ld/testsuite/ld-loongarch-elf/pr.exp - ---- a/bfd/elfnn-loongarch.c -+++ b/bfd/elfnn-loongarch.c -@@ -2342,9 +2342,10 @@ loongarch_elf_relocate_section (bfd *out - case R_LARCH_SOP_PUSH_PLT_PCREL: - unresolved_reloc = false; - -- if (resolved_to_const) -+ if (!is_undefweak && resolved_to_const) - { - relocation += rel->r_addend; -+ relocation -= pc; - break; - } - else if (is_undefweak) ---- /dev/null -+++ b/ld/testsuite/ld-loongarch-elf/pcrel-const.d -@@ -0,0 +1,14 @@ -+#as: -mla-global-with-pcrel -+#objdump: -Drsz -+ -+.*:[ ]+file format .* -+ -+ -+Disassembly of section .text: -+ -+.* : -+#... -+[ ]+8:[ ]+02c04084[ ]+addi.d[ ]+\$a0,[ ]+\$a0,[ ]+16\(0x10\) -+#... -+0+14 <__sec_end>: -+#pass ---- /dev/null -+++ b/ld/testsuite/ld-loongarch-elf/pcrel-const.lds -@@ -0,0 +1,14 @@ -+ENTRY(foo); -+SECTIONS -+{ -+ .text : { -+ *(.text*) -+ } -+ -+ .data : { -+ __sec_start = .; -+ *(.gzdata) -+ __sec_end = .; -+ } -+} -+PROVIDE(__sec_size = __sec_end); ---- /dev/null -+++ b/ld/testsuite/ld-loongarch-elf/pcrel-const.s -@@ -0,0 +1,12 @@ -+ .text -+ .align 2 -+ .globl foo -+ .type foo, @function -+foo: -+ nop -+ la.global $r4,__sec_size -+ ldptr.w $r4,$r4,0 -+ jr $r1 -+ .size foo, .-foo -+ .data -+ .word 1 ---- /dev/null -+++ b/ld/testsuite/ld-loongarch-elf/pr.exp -@@ -0,0 +1,39 @@ -+# Expect script for LoongArch ELF linker tests -+# Copyright (C) 2022 Free Software Foundation, Inc. -+# -+# This file is part of the GNU Binutils. -+# -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -+# MA 02110-1301, USA. -+# -+ -+if ![istarget loongarch64-*-*] { -+ return -+} -+ -+set link_tests [list \ -+ [list \ -+ "pcrel const" \ -+ "-T pcrel-const.lds" "" \ -+ "-mla-global-with-pcrel" \ -+ { pcrel-const.s } \ -+ [list \ -+ [list objdump -D pcrel-const.d] \ -+ ] \ -+ "pcrel-const" \ -+ ] \ -+] -+ -+run_ld_link_tests $link_tests diff --git a/toolchain/binutils/patches/2.39/043-Re-PR29466-APP-NO_APP-with-linefile.patch b/toolchain/binutils/patches/2.39/043-Re-PR29466-APP-NO_APP-with-linefile.patch deleted file mode 100644 index 1de501a1ae..0000000000 --- a/toolchain/binutils/patches/2.39/043-Re-PR29466-APP-NO_APP-with-linefile.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 4233be14a34d754a70b8b6f6fa42d21f35c6e030 Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Sat, 10 Sep 2022 07:30:57 +0930 -Subject: [PATCH 043/160] Re: PR29466, APP/NO_APP with linefile - -It looks like I copied the SIZE init across from -binutils/testsuite/config/default.exp without some necessary editing. - - PR 29466 - * testsuite/config/default.exp (SIZE): Adjust relative path. - -(cherry picked from commit 1180f540d5f2f7751b5309bdd6c38d69fcf699e7) ---- - gas/testsuite/config/default.exp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/gas/testsuite/config/default.exp -+++ b/gas/testsuite/config/default.exp -@@ -53,7 +53,7 @@ if ![info exists NMFLAGS] then { - } - - if ![info exists SIZE] then { -- set SIZE [findfile $base_dir/size] -+ set SIZE [findfile $base_dir/../../binutils/size] - } - - if ![info exists SIZEFLAGS] then { diff --git a/toolchain/binutils/patches/2.39/050-PowerPC64-pcrel-got-relocs-against-local-symbols.patch b/toolchain/binutils/patches/2.39/050-PowerPC64-pcrel-got-relocs-against-local-symbols.patch deleted file mode 100644 index 5c89f6804e..0000000000 --- a/toolchain/binutils/patches/2.39/050-PowerPC64-pcrel-got-relocs-against-local-symbols.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 4d7bba23a39fba18d6d13a2941a3c232011a7064 Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Fri, 16 Sep 2022 18:08:44 +0930 -Subject: [PATCH 050/160] PowerPC64 pcrel got relocs against local symbols - -Not that anyone would want to indirect via the GOT when an address can -be loaded directly with pla, the following: - - pld 3,x@got@pcrel -x: - -leads to "Internal error in md_apply_fix", because the generic parts -of assembler fixup handling convert the fx_pcrel fixup to one without -a symbol. Stop that happening. - - * config/tc-ppc.c (ppc_force_relocation): Add PLT_PCREL34 and - assorted GOT_PCREL34 relocs. - -(cherry picked from commit 49c3ed081fed6b8e2b48fdc48f805f11e4589514) ---- - gas/config/tc-ppc.c | 6 ++++++ - 1 file changed, 6 insertions(+) - ---- a/gas/config/tc-ppc.c -+++ b/gas/config/tc-ppc.c -@@ -6676,6 +6676,12 @@ ppc_force_relocation (fixS *fix) - case BFD_RELOC_PPC_BA16_BRNTAKEN: - case BFD_RELOC_24_PLT_PCREL: - case BFD_RELOC_PPC64_TOC: -+ case BFD_RELOC_PPC64_PLT_PCREL34: -+ case BFD_RELOC_PPC64_GOT_PCREL34: -+ case BFD_RELOC_PPC64_GOT_TLSGD_PCREL34: -+ case BFD_RELOC_PPC64_GOT_TLSLD_PCREL34: -+ case BFD_RELOC_PPC64_GOT_TPREL_PCREL34: -+ case BFD_RELOC_PPC64_GOT_DTPREL_PCREL34: - return 1; - case BFD_RELOC_PPC_B26: - case BFD_RELOC_PPC_BA26: diff --git a/toolchain/binutils/patches/2.39/055-Re-PowerPC64-pcrel-got-relocs-against-local-symbols.patch b/toolchain/binutils/patches/2.39/055-Re-PowerPC64-pcrel-got-relocs-against-local-symbols.patch deleted file mode 100644 index 19b80c3442..0000000000 --- a/toolchain/binutils/patches/2.39/055-Re-PowerPC64-pcrel-got-relocs-against-local-symbols.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 010db38b54b589ca3e95b498aba2831064970171 Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Wed, 21 Sep 2022 09:06:29 +0930 -Subject: [PATCH 055/160] Re: PowerPC64 pcrel got relocs against local symbols - -The last patch wasn't all that shiny. There are rather a lot more -relocations that can hit the assertion in md_apply_fix if the symbol -is local or absolute. Fix them all. - - * config/tc-ppc.c (ppc_force_relocation): Add all relocs that - expect a symbol in md_apply_fix. Remove tls pcrel relocs - already covered in general tls match range. - -(cherry picked from commit 8b168f1a1e09e337d2a970f204a0230c091bbe58) ---- - gas/config/tc-ppc.c | 58 ++++++++++++++++++++++++++++++++++++++++----- - 1 file changed, 52 insertions(+), 6 deletions(-) - ---- a/gas/config/tc-ppc.c -+++ b/gas/config/tc-ppc.c -@@ -6666,8 +6666,6 @@ ppc_force_relocation (fixS *fix) - int - ppc_force_relocation (fixS *fix) - { -- /* Branch prediction relocations must force a relocation, as must -- the vtable description relocs. */ - switch (fix->fx_r_type) - { - case BFD_RELOC_PPC_B16_BRTAKEN: -@@ -6676,12 +6674,60 @@ ppc_force_relocation (fixS *fix) - case BFD_RELOC_PPC_BA16_BRNTAKEN: - case BFD_RELOC_24_PLT_PCREL: - case BFD_RELOC_PPC64_TOC: -+ case BFD_RELOC_16_GOTOFF: -+ case BFD_RELOC_LO16_GOTOFF: -+ case BFD_RELOC_HI16_GOTOFF: -+ case BFD_RELOC_HI16_S_GOTOFF: -+ case BFD_RELOC_LO16_PLTOFF: -+ case BFD_RELOC_HI16_PLTOFF: -+ case BFD_RELOC_HI16_S_PLTOFF: -+ case BFD_RELOC_GPREL16: -+ case BFD_RELOC_16_BASEREL: -+ case BFD_RELOC_LO16_BASEREL: -+ case BFD_RELOC_HI16_BASEREL: -+ case BFD_RELOC_HI16_S_BASEREL: -+ case BFD_RELOC_PPC_TOC16: -+ case BFD_RELOC_PPC64_TOC16_LO: -+ case BFD_RELOC_PPC64_TOC16_HI: -+ case BFD_RELOC_PPC64_TOC16_HA: -+ case BFD_RELOC_PPC64_PLTGOT16: -+ case BFD_RELOC_PPC64_PLTGOT16_LO: -+ case BFD_RELOC_PPC64_PLTGOT16_HI: -+ case BFD_RELOC_PPC64_PLTGOT16_HA: -+ case BFD_RELOC_PPC64_GOT16_DS: -+ case BFD_RELOC_PPC64_GOT16_LO_DS: -+ case BFD_RELOC_PPC64_PLT16_LO_DS: -+ case BFD_RELOC_PPC64_SECTOFF_DS: -+ case BFD_RELOC_PPC64_SECTOFF_LO_DS: -+ case BFD_RELOC_PPC64_TOC16_DS: -+ case BFD_RELOC_PPC64_TOC16_LO_DS: -+ case BFD_RELOC_PPC64_PLTGOT16_DS: -+ case BFD_RELOC_PPC64_PLTGOT16_LO_DS: -+ case BFD_RELOC_PPC_EMB_NADDR16: -+ case BFD_RELOC_PPC_EMB_NADDR16_LO: -+ case BFD_RELOC_PPC_EMB_NADDR16_HI: -+ case BFD_RELOC_PPC_EMB_NADDR16_HA: -+ case BFD_RELOC_PPC_EMB_SDAI16: -+ case BFD_RELOC_PPC_EMB_SDA2I16: -+ case BFD_RELOC_PPC_EMB_SDA2REL: -+ case BFD_RELOC_PPC_EMB_SDA21: -+ case BFD_RELOC_PPC_EMB_MRKREF: -+ case BFD_RELOC_PPC_EMB_RELSEC16: -+ case BFD_RELOC_PPC_EMB_RELST_LO: -+ case BFD_RELOC_PPC_EMB_RELST_HI: -+ case BFD_RELOC_PPC_EMB_RELST_HA: -+ case BFD_RELOC_PPC_EMB_BIT_FLD: -+ case BFD_RELOC_PPC_EMB_RELSDA: -+ case BFD_RELOC_PPC_VLE_SDA21: -+ case BFD_RELOC_PPC_VLE_SDA21_LO: -+ case BFD_RELOC_PPC_VLE_SDAREL_LO16A: -+ case BFD_RELOC_PPC_VLE_SDAREL_LO16D: -+ case BFD_RELOC_PPC_VLE_SDAREL_HI16A: -+ case BFD_RELOC_PPC_VLE_SDAREL_HI16D: -+ case BFD_RELOC_PPC_VLE_SDAREL_HA16A: -+ case BFD_RELOC_PPC_VLE_SDAREL_HA16D: - case BFD_RELOC_PPC64_PLT_PCREL34: - case BFD_RELOC_PPC64_GOT_PCREL34: -- case BFD_RELOC_PPC64_GOT_TLSGD_PCREL34: -- case BFD_RELOC_PPC64_GOT_TLSLD_PCREL34: -- case BFD_RELOC_PPC64_GOT_TPREL_PCREL34: -- case BFD_RELOC_PPC64_GOT_DTPREL_PCREL34: - return 1; - case BFD_RELOC_PPC_B26: - case BFD_RELOC_PPC_BA26: diff --git a/toolchain/binutils/patches/2.39/058-elf-Reset-alignment-for-each-PT_LOAD-segment.patch b/toolchain/binutils/patches/2.39/058-elf-Reset-alignment-for-each-PT_LOAD-segment.patch deleted file mode 100644 index aaf7a1b053..0000000000 --- a/toolchain/binutils/patches/2.39/058-elf-Reset-alignment-for-each-PT_LOAD-segment.patch +++ /dev/null @@ -1,89 +0,0 @@ -From a98316d5cf970cbc99689797d84c2ea832bcdcbb Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" -Date: Mon, 1 Aug 2022 16:02:39 -0700 -Subject: [PATCH 058/160] elf: Reset alignment for each PT_LOAD segment - -Reset alignment for each PT_LOAD segment to avoid using alignment from -the previous PT_LOAD segment. - -bfd/ - - PR ld/29435 - * elf.c (assign_file_positions_for_load_sections): Reset - alignment for each PT_LOAD segment. - -ld/ - - PR ld/29435 - * testsuite/ld-elf/pr29435.d: New file. - * testsuite/ld-elf/pr29435.s: Likewise. - -(cherry picked from commit 59f214544c50ec7ebbca285ff2b4949f48671690) ---- - bfd/elf.c | 7 ++++--- - ld/testsuite/ld-elf/pr29435.d | 11 +++++++++++ - ld/testsuite/ld-elf/pr29435.s | 6 ++++++ - 3 files changed, 21 insertions(+), 3 deletions(-) - create mode 100644 ld/testsuite/ld-elf/pr29435.d - create mode 100644 ld/testsuite/ld-elf/pr29435.s - ---- a/bfd/elf.c -+++ b/bfd/elf.c -@@ -5438,8 +5438,6 @@ assign_file_positions_for_load_sections - Elf_Internal_Phdr *p; - file_ptr off; /* Octets. */ - bfd_size_type maxpagesize; -- bfd_size_type p_align; -- bool p_align_p = false; - unsigned int alloc, actual; - unsigned int i, j; - struct elf_segment_map **sorted_seg_map; -@@ -5524,7 +5522,6 @@ assign_file_positions_for_load_sections - qsort (sorted_seg_map, alloc, sizeof (*sorted_seg_map), - elf_sort_segments); - -- p_align = bed->p_align; - maxpagesize = 1; - if ((abfd->flags & D_PAGED) != 0) - { -@@ -5559,6 +5556,8 @@ assign_file_positions_for_load_sections - asection **secpp; - bfd_vma off_adjust; /* Octets. */ - bool no_contents; -+ bfd_size_type p_align; -+ bool p_align_p; - - /* An ELF segment (described by Elf_Internal_Phdr) may contain a - number of sections with contents contributing to both p_filesz -@@ -5569,6 +5568,8 @@ assign_file_positions_for_load_sections - p = phdrs + m->idx; - p->p_type = m->p_type; - p->p_flags = m->p_flags; -+ p_align = bed->p_align; -+ p_align_p = false; - - if (m->count == 0) - p->p_vaddr = m->p_vaddr_offset * opb; ---- /dev/null -+++ b/ld/testsuite/ld-elf/pr29435.d -@@ -0,0 +1,11 @@ -+#ld: -shared -z separate-code -z relro -+#xfail: ![check_shared_lib_support] -+#xfail: ![check_relro_support] -+#readelf: -Wl -+ -+#failif -+#... -+ +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ .* 0x8000 -+#... -+ +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ .* 0x8000 -+#... ---- /dev/null -+++ b/ld/testsuite/ld-elf/pr29435.s -@@ -0,0 +1,6 @@ -+ .text -+ .balign 0x8000 -+ .globl foo -+ .type foo, %function -+foo: -+ .byte 0 diff --git a/toolchain/binutils/patches/2.39/063-PR29542-PowerPC-gold-internal-error-in-get_output_vi.patch b/toolchain/binutils/patches/2.39/063-PR29542-PowerPC-gold-internal-error-in-get_output_vi.patch deleted file mode 100644 index 0d66b7750f..0000000000 --- a/toolchain/binutils/patches/2.39/063-PR29542-PowerPC-gold-internal-error-in-get_output_vi.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 041c22e35de06d22566f4c71e4425c3351215e66 Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Sun, 25 Sep 2022 12:07:36 +0930 -Subject: [PATCH 063/160] PR29542, PowerPC gold internal error in - get_output_view, - -We were attempting to set a BSS style section contents. - - PR 29542 - * powerpc.cc (Output_data_plt_powerpc::do_write): Don't set .plt, - .iplt or .lplt section contents when position independent. - -(cherry picked from commit c21736aed1d4877e090df60362413669dbdc391d) ---- - gold/powerpc.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - ---- a/gold/powerpc.cc -+++ b/gold/powerpc.cc -@@ -4338,7 +4338,8 @@ template - void - Output_data_plt_powerpc::do_write(Output_file* of) - { -- if (!this->sym_ents_.empty()) -+ if (!this->sym_ents_.empty() -+ && !parameters->options().output_is_position_independent()) - { - const section_size_type offset = this->offset(); - const section_size_type oview_size diff --git a/toolchain/binutils/patches/2.39/116-arm-Use-DWARF-numbering-convention-for-pseudo-regist.patch b/toolchain/binutils/patches/2.39/116-arm-Use-DWARF-numbering-convention-for-pseudo-regist.patch deleted file mode 100644 index 82a015ee2b..0000000000 --- a/toolchain/binutils/patches/2.39/116-arm-Use-DWARF-numbering-convention-for-pseudo-regist.patch +++ /dev/null @@ -1,301 +0,0 @@ -From 88ac930a725b8aac8284a2738f03b843f4343dd0 Mon Sep 17 00:00:00 2001 -From: Victor Do Nascimento -Date: Thu, 17 Nov 2022 14:48:37 +0000 -Subject: [PATCH 116/160] arm: Use DWARF numbering convention for - pseudo-register representation - -The patch, initially submitted to trunk in -https://sourceware.org/pipermail/binutils/2022-July/122092.html ensures correct -support for handling .save directives for mixed-register type lists involving -the ra_auth_code pseudo-register, whereby the support first introduced in 2.39 -(https://sourceware.org/pipermail/binutils/2022-May/120672.html) led to the -generation of unwinder code popping registers in reversed order. - -gas/Changelog: - - * config/tc-arm.c (REG_RA_AUTH_CODE): New. - (parse_dot_save): Likewise. - (parse_reg_list): Remove obsolete code. - (reg_names): Set ra_auth_code to 143. - (s_arm_unwind_save): Handle core and pseudo-register lists via - parse_dot_save. - (s_arm_unwind_save_mixed): Deleted. - (s_arm_unwind_save_pseudo): Handle one register at a time. - * testsuite/gas/arm/unwind-pacbti-m-readelf.d: Fix test. - * testsuite/gas/arm/unwind-pacbti-m.d: Likewise. - -(cherry picked from commit 3a368c4c248f6e9f4bda3a5369befa17a4560293) ---- - gas/config/tc-arm.c | 159 ++++++++++-------- - .../gas/arm/unwind-pacbti-m-readelf.d | 4 +- - gas/testsuite/gas/arm/unwind-pacbti-m.d | 2 +- - 3 files changed, 95 insertions(+), 70 deletions(-) - ---- a/gas/config/tc-arm.c -+++ b/gas/config/tc-arm.c -@@ -742,6 +742,7 @@ const char * const reg_expected_msgs[] = - #define REG_SP 13 - #define REG_LR 14 - #define REG_PC 15 -+#define REG_RA_AUTH_CODE 143 - - /* ARM instructions take 4bytes in the object file, Thumb instructions - take 2: */ -@@ -1943,21 +1944,6 @@ parse_reg_list (char ** strp, enum reg_l - - reg = arm_reg_parse (&str, rt); - -- /* Skip over allowed registers of alternative types in mixed-type -- register lists. */ -- if (reg == FAIL && rt == REG_TYPE_PSEUDO -- && ((reg = arm_reg_parse (&str, REG_TYPE_RN)) != FAIL)) -- { -- cur_reg = reg; -- continue; -- } -- else if (reg == FAIL && rt == REG_TYPE_RN -- && ((reg = arm_reg_parse (&str, REG_TYPE_PSEUDO)) != FAIL)) -- { -- cur_reg = reg; -- continue; -- } -- - if (etype == REGLIST_CLRM) - { - if (reg == REG_SP || reg == REG_PC) -@@ -4139,7 +4125,6 @@ s_arm_unwind_fnstart (int ignored ATTRIB - unwind.sp_restored = 0; - } - -- - /* Parse a handlerdata directive. Creates the exception handling table entry - for the function. */ - -@@ -4297,15 +4282,19 @@ s_arm_unwind_personality (int ignored AT - /* Parse a directive saving pseudo registers. */ - - static void --s_arm_unwind_save_pseudo (long range) -+s_arm_unwind_save_pseudo (int regno) - { - valueT op; - -- if (range & (1 << 12)) -+ switch (regno) - { -+ case REG_RA_AUTH_CODE: - /* Opcode for restoring RA_AUTH_CODE. */ - op = 0xb4; - add_unwind_opcode (op, 1); -+ break; -+ default: -+ as_bad (_("Unknown register %d encountered\n"), regno); - } - } - -@@ -4375,6 +4364,80 @@ s_arm_unwind_save_core (long range) - } - } - -+/* Implement correct handling of .save lists enabling the split into -+sublists where necessary, while preserving correct sublist ordering. */ -+ -+static void -+parse_dot_save (char **str_p, int prev_reg) -+{ -+ long core_regs = 0; -+ int reg; -+ int in_range = 0; -+ -+ if (**str_p == ',') -+ *str_p += 1; -+ if (**str_p == '}') -+ { -+ *str_p += 1; -+ return; -+ } -+ -+ while ((reg = arm_reg_parse (str_p, REG_TYPE_RN)) != FAIL) -+ { -+ if (!in_range) -+ { -+ if (core_regs & (1 << reg)) -+ as_tsktsk (_("Warning: duplicated register (r%d) in register list"), -+ reg); -+ else if (reg <= prev_reg) -+ as_tsktsk (_("Warning: register list not in ascending order")); -+ -+ core_regs |= (1 << reg); -+ prev_reg = reg; -+ if (skip_past_char(str_p, '-') != FAIL) -+ in_range = 1; -+ else if (skip_past_comma(str_p) == FAIL) -+ first_error (_("bad register list")); -+ } -+ else -+ { -+ int i; -+ if (reg <= prev_reg) -+ first_error (_("bad range in register list")); -+ for (i = prev_reg + 1; i <= reg; i++) -+ { -+ if (core_regs & (1 << i)) -+ as_tsktsk (_("Warning: duplicated register (r%d) in register list"), -+ i); -+ else -+ core_regs |= 1 << i; -+ } -+ in_range = 0; -+ } -+ } -+ if (core_regs) -+ { -+ /* Higher register numbers go in higher memory addresses. When splitting a list, -+ right-most sublist should therefore be .saved first. Use recursion for this. */ -+ parse_dot_save (str_p, reg); -+ /* We're back from recursion, so emit .save insn for sublist. */ -+ s_arm_unwind_save_core (core_regs); -+ return; -+ } -+ /* Handle pseudo-regs, under assumption these are emitted singly. */ -+ else if ((reg = arm_reg_parse (str_p, REG_TYPE_PSEUDO)) != FAIL) -+ { -+ /* Recurse for remainder of input. Note: No assumption is made regarding which -+ register in core register set holds pseudo-register. It's not considered in -+ ordering check beyond ensuring it's not sandwiched between 2 consecutive -+ registers. */ -+ parse_dot_save (str_p, prev_reg + 1); -+ s_arm_unwind_save_pseudo (reg); -+ return; -+ } -+ else -+ as_bad (BAD_SYNTAX); -+} - - /* Parse a directive saving FPA registers. */ - -@@ -4716,39 +4779,13 @@ s_arm_unwind_save_mmxwcg (void) - ignore_rest_of_line (); - } - --/* Convert range and mask_range into a sequence of s_arm_unwind_core -- and s_arm_unwind_pseudo operations. We assume that mask_range will -- not have consecutive bits set, or that one operation per bit is -- acceptable. */ -- --static void --s_arm_unwind_save_mixed (long range, long mask_range) --{ -- while (mask_range) -- { -- long mask_bit = mask_range & -mask_range; -- long subrange = range & (mask_bit - 1); -- -- if (subrange) -- s_arm_unwind_save_core (subrange); -- -- s_arm_unwind_save_pseudo (mask_bit); -- range &= ~subrange; -- mask_range &= ~mask_bit; -- } -- -- if (range) -- s_arm_unwind_save_core (range); --} -- - /* Parse an unwind_save directive. - If the argument is non-zero, this is a .vsave directive. */ - - static void - s_arm_unwind_save (int arch_v6) - { -- char *peek, *mask_peek; -- long range, mask_range; -+ char *peek; - struct reg_entry *reg; - bool had_brace = false; - -@@ -4756,7 +4793,7 @@ s_arm_unwind_save (int arch_v6) - as_bad (MISSING_FNSTART); - - /* Figure out what sort of save we have. */ -- peek = mask_peek = input_line_pointer; -+ peek = input_line_pointer; - - if (*peek == '{') - { -@@ -4788,20 +4825,13 @@ s_arm_unwind_save (int arch_v6) - - case REG_TYPE_PSEUDO: - case REG_TYPE_RN: -- mask_range = parse_reg_list (&mask_peek, REGLIST_PSEUDO); -- range = parse_reg_list (&input_line_pointer, REGLIST_RN); -- -- if (range == FAIL || mask_range == FAIL) -- { -- as_bad (_("expected register list")); -- ignore_rest_of_line (); -- return; -- } -- -- demand_empty_rest_of_line (); -- -- s_arm_unwind_save_mixed (range, mask_range); -- return; -+ { -+ if (had_brace) -+ input_line_pointer++; -+ parse_dot_save (&input_line_pointer, -1); -+ demand_empty_rest_of_line (); -+ return; -+ } - - case REG_TYPE_VFD: - if (arch_v6) -@@ -23993,12 +24023,8 @@ static const struct reg_entry reg_names[ - /* XScale accumulator registers. */ - REGNUM(acc,0,XSCALE), REGNUM(ACC,0,XSCALE), - -- /* DWARF ABI defines RA_AUTH_CODE to 143. It also reserves 134-142 for future -- expansion. RA_AUTH_CODE here is given the value 143 % 134 to make it easy -- for tc_arm_regname_to_dw2regnum to translate to DWARF reg number using -- 134 + reg_number should the range 134 to 142 be used for more pseudo regs -- in the future. This also helps fit RA_AUTH_CODE into a bitmask. */ -- REGDEF(ra_auth_code,12,PSEUDO), -+ /* AADWARF32 defines RA_AUTH_CODE to 143. */ -+ REGDEF(ra_auth_code,143,PSEUDO), - }; - #undef REGDEF - #undef REGNUM -@@ -27905,7 +27931,6 @@ create_unwind_entry (int have_data) - return 0; - } - -- - /* Initialize the DWARF-2 unwind information for this procedure. */ - - void ---- a/gas/testsuite/gas/arm/unwind-pacbti-m-readelf.d -+++ b/gas/testsuite/gas/arm/unwind-pacbti-m-readelf.d -@@ -10,11 +10,11 @@ Unwind section '.ARM.exidx' at offset 0x - - 0x0 : @0x0 - Compact model index: 1 -- 0x84 0x00 pop {r14} - 0xb4 pop {ra_auth_code} - 0x84 0x00 pop {r14} -- 0xb4 pop {ra_auth_code} - 0xa3 pop {r4, r5, r6, r7} - 0xb4 pop {ra_auth_code} -+ 0x84 0x00 pop {r14} -+ 0xb4 pop {ra_auth_code} - 0xa8 pop {r4, r14} - 0xb0 finish ---- a/gas/testsuite/gas/arm/unwind-pacbti-m.d -+++ b/gas/testsuite/gas/arm/unwind-pacbti-m.d -@@ -8,4 +8,4 @@ - .*: file format.* - - Contents of section .ARM.extab: -- 0000 (00840281 b40084b4 b0a8b4a3|81028400 b48400b4 a3b4a8b0) 00000000 .* -+ 0000 (84b40281 84b4a300 b0a8b400|8102b484 00a3b484 00b4a8b0) 00000000 .* diff --git a/toolchain/binutils/patches/2.39/300-001_ld_makefile_patch.patch b/toolchain/binutils/patches/2.39/300-001_ld_makefile_patch.patch deleted file mode 100644 index ac80bf4259..0000000000 --- a/toolchain/binutils/patches/2.39/300-001_ld_makefile_patch.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/ld/Makefile.am -+++ b/ld/Makefile.am -@@ -50,7 +50,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) - - EMUL = @EMUL@ - EMULATION_OFILES = @EMULATION_OFILES@ ---- a/ld/Makefile.in -+++ b/ld/Makefile.in -@@ -569,7 +569,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 diff --git a/toolchain/binutils/patches/2.39/400-mips_no_dynamic_linking_sym.patch b/toolchain/binutils/patches/2.39/400-mips_no_dynamic_linking_sym.patch deleted file mode 100644 index f499dfdc02..0000000000 --- a/toolchain/binutils/patches/2.39/400-mips_no_dynamic_linking_sym.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/bfd/elfxx-mips.c -+++ b/bfd/elfxx-mips.c -@@ -8066,6 +8066,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))) -@@ -8078,6 +8079,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) - { diff --git a/toolchain/binutils/patches/2.39/500-Change-default-emulation-for-mips64-linux.patch b/toolchain/binutils/patches/2.39/500-Change-default-emulation-for-mips64-linux.patch deleted file mode 100644 index 8a43563db0..0000000000 --- a/toolchain/binutils/patches/2.39/500-Change-default-emulation-for-mips64-linux.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/bfd/config.bfd -+++ b/bfd/config.bfd -@@ -928,12 +928,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 -@@ -580,12 +580,12 @@ mips*-*-vxworks*) targ_emul=elf32ebmipvx - ;; - 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 diff --git a/toolchain/binutils/patches/2.41/001-PR-30569-always-call-elf_backend_size_dynamic_sectio.patch b/toolchain/binutils/patches/2.41/001-PR-30569-always-call-elf_backend_size_dynamic_sectio.patch deleted file mode 100644 index 8cb7c041b0..0000000000 --- a/toolchain/binutils/patches/2.41/001-PR-30569-always-call-elf_backend_size_dynamic_sectio.patch +++ /dev/null @@ -1,2172 +0,0 @@ -From af969b14aedcc0ae27dcefab4327ff2d153dec8b Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Thu, 28 Mar 2024 19:25:42 +1030 -Subject: [PATCH 1/2] PR 30569, always call elf_backend_size_dynamic_sections - -This largely mechanical patch is preparation for a followup patch. - -For quite some time I've thought that it would be useful to call -elf_backend_size_dynamic_sections even when no dynamic objects are -seen by the linker. That's what this patch does, with some renaming. -There are no functional changes to the linker, just a move of the -dynobj test in bfd_elf_size_dynamic_sections to target backend -functions, replacing the asserts/aborts already there. No doubt some -of the current always_size_sections functions could be moved to -size_dynamic_sections but I haven't made that change. - -Because both hooks are now always called, I have renamed -always_size_sections to early_size_sections and size_dynamic_sections -to late_size_sections. I condisdered calling late_size_sections plain -size_sections, since this is the usual target dynamic section sizing -hook, but decided that searching the sources for "size_sections" would -then hit early_size_sections and other functions. ---- - bfd/elf-bfd.h | 35 +++++++++++++++++------------------ - bfd/elf-m10300.c | 11 ++++++----- - bfd/elf32-arc.c | 9 +++++---- - bfd/elf32-arm.c | 15 ++++++++------- - bfd/elf32-bfin.c | 31 ++++++++++++++++--------------- - bfd/elf32-cr16.c | 11 ++++++----- - bfd/elf32-cris.c | 13 +++++++------ - bfd/elf32-csky.c | 8 ++++---- - bfd/elf32-frv.c | 23 ++++++++++++----------- - bfd/elf32-hppa.c | 8 ++++---- - bfd/elf32-i386.c | 7 +++---- - bfd/elf32-lm32.c | 15 ++++++++------- - bfd/elf32-m32c.c | 8 ++++---- - bfd/elf32-m32r.c | 11 ++++++----- - bfd/elf32-m68k.c | 16 ++++++++-------- - bfd/elf32-metag.c | 8 ++++---- - bfd/elf32-microblaze.c | 9 +++++---- - bfd/elf32-mips.c | 6 ++---- - bfd/elf32-nds32.c | 9 +++++---- - bfd/elf32-nios2.c | 15 ++++++++------- - bfd/elf32-or1k.c | 9 +++++---- - bfd/elf32-ppc.c | 11 ++++++----- - bfd/elf32-rl78.c | 8 ++++---- - bfd/elf32-s390.c | 10 +++++----- - bfd/elf32-score.c | 35 ++++++++++++++++++----------------- - bfd/elf32-score.h | 4 ++-- - bfd/elf32-score7.c | 13 +++++++------ - bfd/elf32-sh.c | 15 +++++++-------- - bfd/elf32-sparc.c | 3 +-- - bfd/elf32-tic6x.c | 14 +++++++------- - bfd/elf32-tilegx.c | 2 +- - bfd/elf32-tilepro.c | 11 +++++------ - bfd/elf32-vax.c | 16 +++++++--------- - bfd/elf32-xstormy16.c | 8 ++++---- - bfd/elf32-xtensa.c | 13 ++++++------- - bfd/elf64-alpha.c | 19 ++++++++++--------- - bfd/elf64-hppa.c | 11 ++++------- - bfd/elf64-ia64-vms.c | 13 +++++++------ - bfd/elf64-mips.c | 8 ++++---- - bfd/elf64-ppc.c | 12 ++++++------ - bfd/elf64-s390.c | 10 +++++----- - bfd/elf64-sparc.c | 4 ++-- - bfd/elf64-tilegx.c | 2 +- - bfd/elf64-x86-64.c | 7 +++---- - bfd/elflink.c | 9 ++++----- - bfd/elfn32-mips.c | 6 ++---- - bfd/elfnn-aarch64.c | 21 +++++++++++---------- - bfd/elfnn-ia64.c | 11 ++++++----- - bfd/elfnn-kvx.c | 19 +++++++++---------- - bfd/elfnn-loongarch.c | 9 +++++---- - bfd/elfnn-riscv.c | 7 ++++--- - bfd/elfxx-mips.c | 15 ++++++++------- - bfd/elfxx-mips.h | 4 ++-- - bfd/elfxx-sparc.c | 7 ++++--- - bfd/elfxx-sparc.h | 2 +- - bfd/elfxx-target.h | 12 ++++++------ - bfd/elfxx-tilegx.c | 7 ++++--- - bfd/elfxx-tilegx.h | 2 +- - bfd/elfxx-x86.c | 8 ++++---- - bfd/elfxx-x86.h | 8 ++++---- - ld/emultempl/vms.em | 7 +++---- - 61 files changed, 343 insertions(+), 337 deletions(-) - ---- a/bfd/elf-bfd.h -+++ b/bfd/elf-bfd.h -@@ -1173,7 +1173,7 @@ struct elf_backend_data - /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend - linker for every symbol which is defined by a dynamic object and - referenced by a regular object. This is called after all the -- input files have been seen, but before the SIZE_DYNAMIC_SECTIONS -+ input files have been seen, but before the LATE_SIZE_SECTIONS - function has been called. The hash table entry should be - bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be - defined in a section from a dynamic object. Dynamic object -@@ -1185,24 +1185,23 @@ struct elf_backend_data - bool (*elf_backend_adjust_dynamic_symbol) - (struct bfd_link_info *info, struct elf_link_hash_entry *h); - -- /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker -- after all the linker input files have been seen but before the -- section sizes have been set. This is called after -- ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS. */ -- bool (*elf_backend_always_size_sections) -+ /* The EARLY_SIZE_SECTIONS and LATE_SIZE_SECTIONS functions are -+ called by the backend linker after all linker input files have -+ been seen and sections have been assigned to output sections, but -+ before the section sizes have been set. Both of these functions -+ are called even when no dynamic object is seen by the linker. -+ Between them, they must set the sizes of the dynamic sections and -+ other backend specific sections, and may fill in their contents. -+ Most backends need only use LATE_SIZE_SECTIONS. -+ EARLY_SIZE_SECTIONS is called before --export-dynamic makes some -+ symbols dynamic and before ADJUST_DYNAMIC_SYMBOL processes -+ dynamic symbols, LATE_SIZE_SECTIONS afterwards. The generic ELF -+ linker can handle the .dynsym, .dynstr and .hash sections. -+ Besides those, these functions must handle the .interp section -+ and any other sections created by CREATE_DYNAMIC_SECTIONS. */ -+ bool (*elf_backend_early_size_sections) - (bfd *output_bfd, struct bfd_link_info *info); -- -- /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend -- linker after all the linker input files have been seen but before -- the sections sizes have been set. This is called after -- ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols. -- It is only called when linking against a dynamic object. It must -- set the sizes of the dynamic sections, and may fill in their -- contents as well. The generic ELF linker can handle the .dynsym, -- .dynstr and .hash sections. This function must handle the -- .interp section and any sections created by the -- CREATE_DYNAMIC_SECTIONS entry point. */ -- bool (*elf_backend_size_dynamic_sections) -+ bool (*elf_backend_late_size_sections) - (bfd *output_bfd, struct bfd_link_info *info); - - /* The STRIP_ZERO_SIZED_DYNAMIC_SECTIONS function is called by the ---- a/bfd/elf-m10300.c -+++ b/bfd/elf-m10300.c -@@ -5015,8 +5015,8 @@ _bfd_mn10300_elf_adjust_dynamic_symbol ( - /* Set the sizes of the dynamic sections. */ - - static bool --_bfd_mn10300_elf_size_dynamic_sections (bfd * output_bfd, -- struct bfd_link_info * info) -+_bfd_mn10300_elf_late_size_sections (bfd * output_bfd, -+ struct bfd_link_info * info) - { - struct elf32_mn10300_link_hash_table *htab = elf32_mn10300_hash_table (info); - bfd * dynobj; -@@ -5024,7 +5024,8 @@ _bfd_mn10300_elf_size_dynamic_sections ( - bool relocs; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5511,8 +5512,8 @@ mn10300_elf_mkobject (bfd *abfd) - _bfd_mn10300_elf_create_dynamic_sections - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mn10300_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- _bfd_mn10300_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_mn10300_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_symbol \ - _bfd_mn10300_elf_finish_dynamic_symbol ---- a/bfd/elf32-arc.c -+++ b/bfd/elf32-arc.c -@@ -2702,8 +2702,8 @@ elf_arc_finish_dynamic_sections (bfd * o - - /* Set the sizes of the dynamic sections. */ - static bool --elf_arc_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_arc_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -2711,7 +2711,8 @@ elf_arc_size_dynamic_sections (bfd *outp - struct elf_link_hash_table *htab = elf_hash_table (info); - - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->dynamic_sections_created) - { -@@ -3127,7 +3128,7 @@ arc_elf_relax_section (bfd *abfd, asecti - #define elf_backend_finish_dynamic_symbol elf_arc_finish_dynamic_symbol - - #define elf_backend_finish_dynamic_sections elf_arc_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf_arc_size_dynamic_sections -+#define elf_backend_late_size_sections elf_arc_late_size_sections - - #define elf_backend_can_gc_sections 1 - #define elf_backend_want_got_plt 1 ---- a/bfd/elf32-arm.c -+++ b/bfd/elf32-arm.c -@@ -16751,8 +16751,8 @@ bfd_elf32_arm_set_byteswap_code (struct - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info * info) -+elf32_arm_late_size_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info * info) - { - bfd * dynobj; - asection * s; -@@ -16765,7 +16765,9 @@ elf32_arm_size_dynamic_sections (bfd * o - return false; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; -+ - check_use_blx (htab); - - if (elf_hash_table (info)->dynamic_sections_created) -@@ -17137,8 +17139,7 @@ elf32_arm_size_dynamic_sections (bfd * o - _TLS_MODULE_BASE_, if needed. */ - - static bool --elf32_arm_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_arm_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - asection *tls_sec; - struct elf32_arm_link_hash_table *htab; -@@ -20332,8 +20333,8 @@ elf32_arm_backend_symbol_processing (bfd - #define elf_backend_create_dynamic_sections elf32_arm_create_dynamic_sections - #define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections --#define elf_backend_always_size_sections elf32_arm_always_size_sections -+#define elf_backend_late_size_sections elf32_arm_late_size_sections -+#define elf_backend_early_size_sections elf32_arm_early_size_sections - #define elf_backend_init_index_section _bfd_elf_init_2_index_sections - #define elf_backend_init_file_header elf32_arm_init_file_header - #define elf_backend_reloc_type_class elf32_arm_reloc_type_class ---- a/bfd/elf32-bfin.c -+++ b/bfd/elf32-bfin.c -@@ -4027,8 +4027,8 @@ _bfinfdpic_size_got_plt (bfd *output_bfd - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_bfinfdpic_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_bfinfdpic_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct elf_link_hash_table *htab; - bfd *dynobj; -@@ -4037,7 +4037,8 @@ elf32_bfinfdpic_size_dynamic_sections (b - - htab = elf_hash_table (info); - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->dynamic_sections_created) - { -@@ -4086,7 +4087,7 @@ elf32_bfinfdpic_size_dynamic_sections (b - } - - static bool --elf32_bfinfdpic_always_size_sections (bfd *output_bfd, -+elf32_bfinfdpic_early_size_sections (bfd *output_bfd, - struct bfd_link_info *info) - { - if (!bfd_link_relocatable (info) -@@ -5123,15 +5124,16 @@ bfin_discard_copies (struct elf_link_has - } - - static bool --bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+bfin_late_size_sections (bfd * output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5423,8 +5425,7 @@ struct bfd_elf_special_section const elf - #define elf_backend_check_relocs bfin_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - bfin_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- bfin_size_dynamic_sections -+#define elf_backend_late_size_sections bfin_late_size_sections - #define elf_backend_relocate_section bfin_relocate_section - #define elf_backend_finish_dynamic_symbol \ - bfin_finish_dynamic_symbol -@@ -5470,9 +5471,9 @@ struct bfd_elf_special_section const elf - #undef bfd_elf32_bfd_link_hash_table_create - #define bfd_elf32_bfd_link_hash_table_create \ - bfinfdpic_elf_link_hash_table_create --#undef elf_backend_always_size_sections --#define elf_backend_always_size_sections \ -- elf32_bfinfdpic_always_size_sections -+#undef elf_backend_early_size_sections -+#define elf_backend_early_size_sections \ -+ elf32_bfinfdpic_early_size_sections - - #undef elf_backend_create_dynamic_sections - #define elf_backend_create_dynamic_sections \ -@@ -5480,9 +5481,9 @@ struct bfd_elf_special_section const elf - #undef elf_backend_adjust_dynamic_symbol - #define elf_backend_adjust_dynamic_symbol \ - elf32_bfinfdpic_adjust_dynamic_symbol --#undef elf_backend_size_dynamic_sections --#define elf_backend_size_dynamic_sections \ -- elf32_bfinfdpic_size_dynamic_sections -+#undef elf_backend_late_size_sections -+#define elf_backend_late_size_sections \ -+ elf32_bfinfdpic_late_size_sections - #undef elf_backend_finish_dynamic_symbol - #define elf_backend_finish_dynamic_symbol \ - elf32_bfinfdpic_finish_dynamic_symbol ---- a/bfd/elf32-cr16.c -+++ b/bfd/elf32-cr16.c -@@ -2391,15 +2391,16 @@ _bfd_cr16_elf_adjust_dynamic_symbol (str - /* Set the sizes of the dynamic sections. */ - - static bool --_bfd_cr16_elf_size_dynamic_sections (bfd * output_bfd, -- struct bfd_link_info * info) -+_bfd_cr16_elf_late_size_sections (bfd * output_bfd, -+ struct bfd_link_info * info) - { - bfd * dynobj; - asection * s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -2836,8 +2837,8 @@ _bfd_cr16_elf_reloc_type_class (const st - _bfd_cr16_elf_create_dynamic_sections - #define elf_backend_adjust_dynamic_symbol \ - _bfd_cr16_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- _bfd_cr16_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_cr16_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_symbol \ - _bfd_cr16_elf_finish_dynamic_symbol ---- a/bfd/elf32-cris.c -+++ b/bfd/elf32-cris.c -@@ -2527,7 +2527,7 @@ cris_elf_plt_sym_val (bfd_vma i ATTRIBUT - entry but we found we will not create any. Called when we find we will - not have any PLT for this symbol, by for example - elf_cris_adjust_dynamic_symbol when we're doing a proper dynamic link, -- or elf_cris_size_dynamic_sections if no dynamic sections will be -+ or elf_cris_late_size_sections if no dynamic sections will be - created (we're only linking static objects). */ - - static bool -@@ -3508,8 +3508,8 @@ cris_elf_check_relocs (bfd *abfd, - /* Set the sizes of the dynamic sections. */ - - static bool --elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_cris_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_cris_link_hash_table * htab; - bfd *dynobj; -@@ -3521,7 +3521,8 @@ elf_cris_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -4090,8 +4091,8 @@ elf_cris_got_elt_size (bfd *abfd ATTRIBU - elf_cris_adjust_dynamic_symbol - #define elf_backend_copy_indirect_symbol \ - elf_cris_copy_indirect_symbol --#define elf_backend_size_dynamic_sections \ -- elf_cris_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elf_cris_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_finish_dynamic_symbol \ - elf_cris_finish_dynamic_symbol ---- a/bfd/elf32-csky.c -+++ b/bfd/elf32-csky.c -@@ -1893,8 +1893,8 @@ csky_allocate_dynrelocs (struct elf_link - /* Set the sizes of the dynamic sections. */ - - static bool --csky_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+csky_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct csky_elf_link_hash_table *htab; - bfd *dynobj; -@@ -1907,7 +1907,7 @@ csky_elf_size_dynamic_sections (bfd *out - return false; - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- return false; -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -5333,7 +5333,7 @@ elf32_csky_obj_attrs_handle_unknown (bfd - /* Dynamic relocate related API. */ - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_adjust_dynamic_symbol csky_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections csky_elf_size_dynamic_sections -+#define elf_backend_late_size_sections csky_elf_late_size_sections - #define elf_backend_finish_dynamic_symbol csky_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections csky_elf_finish_dynamic_sections - #define elf_backend_rela_normal 1 ---- a/bfd/elf32-frv.c -+++ b/bfd/elf32-frv.c -@@ -5423,15 +5423,16 @@ _frvfdpic_size_got_plt (bfd *output_bfd, - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_frvfdpic_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_frvfdpic_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - struct _frvfdpic_dynamic_got_plt_info gpinfo; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5472,8 +5473,8 @@ elf32_frvfdpic_size_dynamic_sections (bf - } - - static bool --elf32_frvfdpic_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf32_frvfdpic_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - if (!bfd_link_relocatable (info) - && !bfd_elf_stack_segment_size (output_bfd, info, -@@ -6817,9 +6818,9 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_In - #undef bfd_elf32_bfd_link_hash_table_create - #define bfd_elf32_bfd_link_hash_table_create \ - frvfdpic_elf_link_hash_table_create --#undef elf_backend_always_size_sections --#define elf_backend_always_size_sections \ -- elf32_frvfdpic_always_size_sections -+#undef elf_backend_early_size_sections -+#define elf_backend_early_size_sections \ -+ elf32_frvfdpic_early_size_sections - - #undef elf_backend_create_dynamic_sections - #define elf_backend_create_dynamic_sections \ -@@ -6827,9 +6828,9 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_In - #undef elf_backend_adjust_dynamic_symbol - #define elf_backend_adjust_dynamic_symbol \ - elf32_frvfdpic_adjust_dynamic_symbol --#undef elf_backend_size_dynamic_sections --#define elf_backend_size_dynamic_sections \ -- elf32_frvfdpic_size_dynamic_sections -+#undef elf_backend_late_size_sections -+#define elf_backend_late_size_sections \ -+ elf32_frvfdpic_late_size_sections - #undef bfd_elf32_bfd_relax_section - #define bfd_elf32_bfd_relax_section \ - elf32_frvfdpic_relax_section ---- a/bfd/elf32-hppa.c -+++ b/bfd/elf32-hppa.c -@@ -2042,8 +2042,8 @@ clobber_millicode_symbols (struct elf_li - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf32_hppa_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf32_hppa_link_hash_table *htab; - bfd *dynobj; -@@ -2057,7 +2057,7 @@ elf32_hppa_size_dynamic_sections (bfd *o - - dynobj = htab->etab.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->etab.dynamic_sections_created) - { -@@ -4450,7 +4450,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Inte - #define elf_backend_hide_symbol elf32_hppa_hide_symbol - #define elf_backend_finish_dynamic_symbol elf32_hppa_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections elf32_hppa_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf32_hppa_size_dynamic_sections -+#define elf_backend_late_size_sections elf32_hppa_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_gc_mark_hook elf32_hppa_gc_mark_hook - #define elf_backend_grok_prstatus elf32_hppa_grok_prstatus ---- a/bfd/elf32-i386.c -+++ b/bfd/elf32-i386.c -@@ -1947,8 +1947,7 @@ elf_i386_scan_relocs (bfd *abfd, - } - - static bool --elf_i386_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf_i386_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *abfd; - -@@ -1961,7 +1960,7 @@ elf_i386_always_size_sections (bfd *outp - elf_i386_scan_relocs)) - return false; - -- return _bfd_x86_elf_always_size_sections (output_bfd, info); -+ return _bfd_x86_elf_early_size_sections (output_bfd, info); - } - - /* Set the correct type for an x86 ELF section. We do this by the -@@ -4469,7 +4468,7 @@ elf_i386_link_setup_gnu_properties (stru - #define bfd_elf32_get_synthetic_symtab elf_i386_get_synthetic_symtab - - #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible --#define elf_backend_always_size_sections elf_i386_always_size_sections -+#define elf_backend_early_size_sections elf_i386_early_size_sections - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_fake_sections elf_i386_fake_sections - #define elf_backend_finish_dynamic_sections elf_i386_finish_dynamic_sections ---- a/bfd/elf32-lm32.c -+++ b/bfd/elf32-lm32.c -@@ -1906,8 +1906,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --lm32_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+lm32_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct elf_lm32_link_hash_table *htab; - bfd *dynobj; -@@ -1920,7 +1920,8 @@ lm32_elf_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -2309,7 +2310,7 @@ lm32_elf_create_dynamic_sections (bfd *a - } - - static bool --lm32_elf_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+lm32_elf_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - if (!bfd_link_relocatable (info)) - { -@@ -2395,7 +2396,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bf - #define bfd_elf32_bfd_link_hash_table_create lm32_elf_link_hash_table_create - #define elf_backend_check_relocs lm32_elf_check_relocs - #define elf_backend_reloc_type_class lm32_elf_reloc_type_class --#define elf_backend_size_dynamic_sections lm32_elf_size_dynamic_sections -+#define elf_backend_late_size_sections lm32_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_create_dynamic_sections lm32_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections lm32_elf_finish_dynamic_sections -@@ -2416,8 +2417,8 @@ lm32_elf_fdpic_copy_private_bfd_data (bf - #undef elf32_bed - #define elf32_bed elf32_lm32fdpic_bed - --#undef elf_backend_always_size_sections --#define elf_backend_always_size_sections lm32_elf_always_size_sections -+#undef elf_backend_early_size_sections -+#define elf_backend_early_size_sections lm32_elf_early_size_sections - #undef bfd_elf32_bfd_copy_private_bfd_data - #define bfd_elf32_bfd_copy_private_bfd_data lm32_elf_fdpic_copy_private_bfd_data - ---- a/bfd/elf32-m32c.c -+++ b/bfd/elf32-m32c.c -@@ -773,8 +773,8 @@ m32c_elf_finish_dynamic_sections (bfd *a - } - - static bool --m32c_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+m32c_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *splt; -@@ -2132,8 +2132,8 @@ _bfd_m32c_elf_eh_frame_address_size (bfd - #define elf_backend_check_relocs m32c_elf_check_relocs - #define elf_backend_object_p m32c_elf_object_p - #define elf_symbol_leading_char ('_') --#define elf_backend_always_size_sections \ -- m32c_elf_always_size_sections -+#define elf_backend_early_size_sections \ -+ m32c_elf_early_size_sections - #define elf_backend_finish_dynamic_sections \ - m32c_elf_finish_dynamic_sections - ---- a/bfd/elf32-m32r.c -+++ b/bfd/elf32-m32r.c -@@ -1958,8 +1958,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+m32r_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_link_hash_table *htab; - bfd *dynobj; -@@ -1968,7 +1968,7 @@ m32r_elf_size_dynamic_sections (bfd *out - bfd *ibfd; - - #ifdef DEBUG_PIC -- printf ("m32r_elf_size_dynamic_sections()\n"); -+ printf ("m32r_elf_late_size_sections()\n"); - #endif - - htab = m32r_elf_hash_table (info); -@@ -1976,7 +1976,8 @@ m32r_elf_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->dynamic_sections_created) - { -@@ -3658,7 +3659,7 @@ m32r_elf_reloc_type_class (const struct - - #define elf_backend_create_dynamic_sections m32r_elf_create_dynamic_sections - #define bfd_elf32_bfd_link_hash_table_create m32r_elf_link_hash_table_create --#define elf_backend_size_dynamic_sections m32r_elf_size_dynamic_sections -+#define elf_backend_late_size_sections m32r_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_sections m32r_elf_finish_dynamic_sections - #define elf_backend_adjust_dynamic_symbol m32r_elf_adjust_dynamic_symbol ---- a/bfd/elf32-m68k.c -+++ b/bfd/elf32-m68k.c -@@ -2934,7 +2934,7 @@ elf_m68k_get_plt_info (bfd *output_bfd) - It's a convenient place to determine the PLT style. */ - - static bool --elf_m68k_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf_m68k_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - /* Bind input BFDs to GOTs and calculate sizes of .got and .rela.got - sections. */ -@@ -3107,15 +3107,16 @@ elf_m68k_adjust_dynamic_symbol (struct b - /* Set the sizes of the dynamic sections. */ - - static bool --elf_m68k_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_m68k_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -4628,12 +4629,11 @@ elf_m68k_grok_psinfo (bfd *abfd, Elf_Int - #define bfd_elf32_bfd_final_link bfd_elf_final_link - - #define elf_backend_check_relocs elf_m68k_check_relocs --#define elf_backend_always_size_sections \ -- elf_m68k_always_size_sections -+#define elf_backend_early_size_sections \ -+ elf_m68k_early_size_sections - #define elf_backend_adjust_dynamic_symbol \ - elf_m68k_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- elf_m68k_size_dynamic_sections -+#define elf_backend_late_size_sections elf_m68k_late_size_sections - #define elf_backend_final_write_processing elf_m68k_final_write_processing - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section elf_m68k_relocate_section ---- a/bfd/elf32-metag.c -+++ b/bfd/elf32-metag.c -@@ -2717,8 +2717,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_metag_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_metag_link_hash_table *htab; - bfd *dynobj; -@@ -2729,7 +2729,7 @@ elf_metag_size_dynamic_sections (bfd *ou - htab = metag_link_hash_table (info); - dynobj = htab->etab.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->etab.dynamic_sections_created) - { -@@ -4019,7 +4019,7 @@ elf_metag_plt_sym_val (bfd_vma i, const - #define elf_backend_adjust_dynamic_symbol elf_metag_adjust_dynamic_symbol - #define elf_backend_finish_dynamic_symbol elf_metag_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections elf_metag_finish_dynamic_sections --#define elf_backend_size_dynamic_sections elf_metag_size_dynamic_sections -+#define elf_backend_late_size_sections elf_metag_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_init_file_header elf_metag_init_file_header ---- a/bfd/elf32-microblaze.c -+++ b/bfd/elf32-microblaze.c -@@ -2946,8 +2946,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+microblaze_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf32_mb_link_hash_table *htab; - bfd *dynobj; -@@ -2959,7 +2959,8 @@ microblaze_elf_size_dynamic_sections (bf - return false; - - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - /* Set up .got offsets for local syms, and space for local dynamic - relocs. */ -@@ -3477,7 +3478,7 @@ microblaze_elf_add_symbol_hook (bfd *abf - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections microblaze_elf_finish_dynamic_sections - #define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol --#define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections -+#define elf_backend_late_size_sections microblaze_elf_late_size_sections - #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook - - #include "elf32-target.h" ---- a/bfd/elf32-mips.c -+++ b/bfd/elf32-mips.c -@@ -2537,10 +2537,8 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_mips_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_mips_elf_size_dynamic_sections -+#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections -+#define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf32-nds32.c -+++ b/bfd/elf32-nds32.c -@@ -4302,8 +4302,8 @@ elf32_nds32_add_dynreloc (bfd *output_bf - /* Set the sizes of the dynamic sections. */ - - static bool --nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+nds32_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_nds32_link_hash_table *htab; - bfd *dynobj; -@@ -4316,7 +4316,8 @@ nds32_elf_size_dynamic_sections (bfd *ou - return false; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -13984,7 +13985,7 @@ nds32_elf_unify_tls_model (bfd *inbfd, a - #define elf_backend_create_dynamic_sections nds32_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections nds32_elf_finish_dynamic_sections - #define elf_backend_finish_dynamic_symbol nds32_elf_finish_dynamic_symbol --#define elf_backend_size_dynamic_sections nds32_elf_size_dynamic_sections -+#define elf_backend_late_size_sections nds32_elf_late_size_sections - #define elf_backend_relocate_section nds32_elf_relocate_section - #define elf_backend_gc_mark_hook nds32_elf_gc_mark_hook - #define elf_backend_grok_prstatus nds32_elf_grok_prstatus ---- a/bfd/elf32-nios2.c -+++ b/bfd/elf32-nios2.c -@@ -5405,7 +5405,7 @@ nios2_elf32_adjust_dynamic_symbol (struc - return true; - } - --/* Worker function for nios2_elf32_size_dynamic_sections. */ -+/* Worker function for nios2_elf32_late_size_sections. */ - static bool - adjust_dynrelocs (struct elf_link_hash_entry *h, void *inf) - { -@@ -5432,7 +5432,7 @@ adjust_dynrelocs (struct elf_link_hash_e - return true; - } - --/* Another worker function for nios2_elf32_size_dynamic_sections. -+/* Another worker function for nios2_elf32_late_size_sections. - Allocate space in .plt, .got and associated reloc sections for - dynamic relocs. */ - static bool -@@ -5667,11 +5667,11 @@ allocate_dynrelocs (struct elf_link_hash - return true; - } - --/* Implement elf_backend_size_dynamic_sections: -+/* Implement elf_backend_late_size_sections: - Set the sizes of the dynamic sections. */ - static bool --nios2_elf32_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+nios2_elf32_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -5681,7 +5681,8 @@ nios2_elf32_size_dynamic_sections (bfd * - - htab = elf32_nios2_hash_table (info); - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - htab->res_n_size = 0; - if (htab->root.dynamic_sections_created) -@@ -6052,7 +6053,7 @@ const struct bfd_elf_special_section elf - nios2_elf32_finish_dynamic_sections - #define elf_backend_adjust_dynamic_symbol nios2_elf32_adjust_dynamic_symbol - #define elf_backend_reloc_type_class nios2_elf32_reloc_type_class --#define elf_backend_size_dynamic_sections nios2_elf32_size_dynamic_sections -+#define elf_backend_late_size_sections nios2_elf32_late_size_sections - #define elf_backend_add_symbol_hook nios2_elf_add_symbol_hook - #define elf_backend_copy_indirect_symbol nios2_elf32_copy_indirect_symbol - #define elf_backend_object_p nios2_elf32_object_p ---- a/bfd/elf32-or1k.c -+++ b/bfd/elf32-or1k.c -@@ -3047,8 +3047,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+or1k_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_or1k_link_hash_table *htab; - bfd *dynobj; -@@ -3061,7 +3061,8 @@ or1k_elf_size_dynamic_sections (bfd *out - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -3414,7 +3415,7 @@ or1k_grok_psinfo (bfd *abfd, Elf_Interna - #define elf_backend_copy_indirect_symbol or1k_elf_copy_indirect_symbol - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections or1k_elf_finish_dynamic_sections --#define elf_backend_size_dynamic_sections or1k_elf_size_dynamic_sections -+#define elf_backend_late_size_sections or1k_elf_late_size_sections - #define elf_backend_adjust_dynamic_symbol or1k_elf_adjust_dynamic_symbol - #define elf_backend_finish_dynamic_symbol or1k_elf_finish_dynamic_symbol - ---- a/bfd/elf32-ppc.c -+++ b/bfd/elf32-ppc.c -@@ -5481,8 +5481,8 @@ static const unsigned char glink_eh_fram - /* Set the sizes of the dynamic sections. */ - - static bool --ppc_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+ppc_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct ppc_elf_link_hash_table *htab; - asection *s; -@@ -5490,11 +5490,12 @@ ppc_elf_size_dynamic_sections (bfd *outp - bfd *ibfd; - - #ifdef DEBUG -- fprintf (stderr, "ppc_elf_size_dynamic_sections called\n"); -+ fprintf (stderr, "ppc_elf_late_size_sections called\n"); - #endif - - htab = ppc_elf_hash_table (info); -- BFD_ASSERT (htab->elf.dynobj != NULL); -+ if (htab->elf.dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -10418,7 +10419,7 @@ ppc_elf_finish_dynamic_sections (bfd *ou - #define elf_backend_copy_indirect_symbol ppc_elf_copy_indirect_symbol - #define elf_backend_adjust_dynamic_symbol ppc_elf_adjust_dynamic_symbol - #define elf_backend_add_symbol_hook ppc_elf_add_symbol_hook --#define elf_backend_size_dynamic_sections ppc_elf_size_dynamic_sections -+#define elf_backend_late_size_sections ppc_elf_late_size_sections - #define elf_backend_hash_symbol ppc_elf_hash_symbol - #define elf_backend_finish_dynamic_symbol ppc_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections ppc_elf_finish_dynamic_sections ---- a/bfd/elf32-rl78.c -+++ b/bfd/elf32-rl78.c -@@ -1440,8 +1440,8 @@ rl78_elf_finish_dynamic_sections (bfd *a - } - - static bool --rl78_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+rl78_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *splt; -@@ -2610,8 +2610,8 @@ rl78_elf_relax_section (bfd *abfd, - - #define bfd_elf32_bfd_relax_section rl78_elf_relax_section - #define elf_backend_check_relocs rl78_elf_check_relocs --#define elf_backend_always_size_sections \ -- rl78_elf_always_size_sections -+#define elf_backend_early_size_sections \ -+ rl78_elf_early_size_sections - #define elf_backend_finish_dynamic_sections \ - rl78_elf_finish_dynamic_sections - ---- a/bfd/elf32-s390.c -+++ b/bfd/elf32-s390.c -@@ -1366,7 +1366,7 @@ elf_s390_gc_mark_hook (asection *sec, - entry but we found we will not create any. Called when we find we will - not have any PLT for this symbol, by for example - elf_s390_adjust_dynamic_symbol when we're doing a proper dynamic link, -- or elf_s390_size_dynamic_sections if no dynamic sections will be -+ or elf_s390_late_size_sections if no dynamic sections will be - created (we're only linking static objects). */ - - static void -@@ -1778,8 +1778,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_s390_link_hash_table *htab; - bfd *dynobj; -@@ -1790,7 +1790,7 @@ elf_s390_size_dynamic_sections (bfd *out - htab = elf_s390_hash_table (info); - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -3926,7 +3926,7 @@ elf32_s390_merge_private_bfd_data (bfd * - #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook - #define elf_backend_reloc_type_class elf_s390_reloc_type_class - #define elf_backend_relocate_section elf_s390_relocate_section --#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections -+#define elf_backend_late_size_sections elf_s390_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_grok_prstatus elf_s390_grok_prstatus - #define elf_backend_grok_psinfo elf_s390_grok_psinfo ---- a/bfd/elf32-score.c -+++ b/bfd/elf32-score.c -@@ -1089,7 +1089,7 @@ score_elf_got_info (bfd *abfd, asection - appear towards the end. This reduces the amount of GOT space - required. MAX_LOCAL is used to set the number of local symbols - known to be in the dynamic symbol table. During -- s3_bfd_score_elf_size_dynamic_sections, this value is 1. Afterward, the -+ s3_bfd_score_elf_late_size_sections, this value is 1. Afterward, the - section symbols are added and the count is higher. */ - static bool - score_elf_sort_hash_table (struct bfd_link_info *info, -@@ -3160,8 +3160,8 @@ s3_bfd_score_elf_adjust_dynamic_symbol ( - /* This function is called after all the input files have been read, - and the input sections have been assigned to output sections. */ - static bool --s3_bfd_score_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+s3_bfd_score_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -3237,14 +3237,15 @@ s3_bfd_score_elf_always_size_sections (b - - /* Set the sizes of the dynamic sections. */ - static bool --s3_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+s3_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool reltext; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -3313,7 +3314,7 @@ s3_bfd_score_elf_size_dynamic_sections ( - } - else if (startswith (name, ".got")) - { -- /* s3_bfd_score_elf_always_size_sections() has already done -+ /* s3_bfd_score_elf_early_size_sections() has already done - most of the work, but some symbols may have been mapped - to versions that we must now resolve in the got_entries - hash tables. */ -@@ -4177,22 +4178,22 @@ _bfd_score_elf_adjust_dynamic_symbol (st - } - - static bool --_bfd_score_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_score_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - if (bfd_get_mach (output_bfd) == bfd_mach_score3) -- return s3_bfd_score_elf_always_size_sections (output_bfd, info); -+ return s3_bfd_score_elf_early_size_sections (output_bfd, info); - else -- return s7_bfd_score_elf_always_size_sections (output_bfd, info); -+ return s7_bfd_score_elf_early_size_sections (output_bfd, info); - } - - static bool --_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - if (bfd_get_mach (output_bfd) == bfd_mach_score3) -- return s3_bfd_score_elf_size_dynamic_sections (output_bfd, info); -+ return s3_bfd_score_elf_late_size_sections (output_bfd, info); - else -- return s7_bfd_score_elf_size_dynamic_sections (output_bfd, info); -+ return s7_bfd_score_elf_late_size_sections (output_bfd, info); - } - - static bool -@@ -4455,10 +4456,10 @@ _bfd_score_elf_common_definition (Elf_In - _bfd_score_elf_section_from_bfd_section - #define elf_backend_adjust_dynamic_symbol \ - _bfd_score_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_score_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_score_elf_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ _bfd_score_elf_early_size_sections -+#define elf_backend_late_size_sections \ -+ _bfd_score_elf_late_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_create_dynamic_sections \ - _bfd_score_elf_create_dynamic_sections ---- a/bfd/elf32-score.h -+++ b/bfd/elf32-score.h -@@ -78,10 +78,10 @@ s7_bfd_score_elf_adjust_dynamic_symbol ( - struct elf_link_hash_entry *); - - extern bool --s7_bfd_score_elf_always_size_sections (bfd *, struct bfd_link_info *); -+s7_bfd_score_elf_early_size_sections (bfd *, struct bfd_link_info *); - - extern bool --s7_bfd_score_elf_size_dynamic_sections (bfd *, struct bfd_link_info *); -+s7_bfd_score_elf_late_size_sections (bfd *, struct bfd_link_info *); - - extern bool - s7_bfd_score_elf_create_dynamic_sections (bfd *, struct bfd_link_info *); ---- a/bfd/elf32-score7.c -+++ b/bfd/elf32-score7.c -@@ -975,7 +975,7 @@ score_elf_got_info (bfd *abfd, asection - appear towards the end. This reduces the amount of GOT space - required. MAX_LOCAL is used to set the number of local symbols - known to be in the dynamic symbol table. During -- s7_bfd_score_elf_size_dynamic_sections, this value is 1. Afterward, the -+ s7_bfd_score_elf_late_size_sections, this value is 1. Afterward, the - section symbols are added and the count is higher. */ - - static bool -@@ -2969,8 +2969,8 @@ s7_bfd_score_elf_adjust_dynamic_symbol ( - and the input sections have been assigned to output sections. */ - - bool --s7_bfd_score_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+s7_bfd_score_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -3047,14 +3047,15 @@ s7_bfd_score_elf_always_size_sections (b - /* Set the sizes of the dynamic sections. */ - - bool --s7_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+s7_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool reltext; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -3123,7 +3124,7 @@ s7_bfd_score_elf_size_dynamic_sections ( - } - else if (startswith (name, ".got")) - { -- /* s7_bfd_score_elf_always_size_sections() has already done -+ /* s7_bfd_score_elf_early_size_sections() has already done - most of the work, but some symbols may have been mapped - to versions that we must now resolve in the got_entries - hash tables. */ ---- a/bfd/elf32-sh.c -+++ b/bfd/elf32-sh.c -@@ -2927,7 +2927,7 @@ allocate_dynrelocs (struct elf_link_hash - It's a convenient place to determine the PLT style. */ - - static bool --sh_elf_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+sh_elf_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - sh_elf_hash_table (info)->plt_info = get_plt_info (output_bfd, - bfd_link_pic (info)); -@@ -2942,8 +2942,8 @@ sh_elf_always_size_sections (bfd *output - /* Set the sizes of the dynamic sections. */ - - static bool --sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+sh_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_sh_link_hash_table *htab; - bfd *dynobj; -@@ -2956,7 +2956,8 @@ sh_elf_size_dynamic_sections (bfd *outpu - return false; - - dynobj = htab->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -6602,10 +6603,8 @@ sh_elf_encode_eh_address (bfd *abfd, - sh_elf_link_hash_table_create - #define elf_backend_adjust_dynamic_symbol \ - sh_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- sh_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- sh_elf_size_dynamic_sections -+#define elf_backend_early_size_sections sh_elf_early_size_sections -+#define elf_backend_late_size_sections sh_elf_late_size_sections - #define elf_backend_omit_section_dynsym sh_elf_omit_section_dynsym - #define elf_backend_finish_dynamic_symbol \ - sh_elf_finish_dynamic_symbol ---- a/bfd/elf32-sparc.c -+++ b/bfd/elf32-sparc.c -@@ -248,8 +248,7 @@ elf32_sparc_reloc_type_class (const stru - #define elf_backend_adjust_dynamic_symbol \ - _bfd_sparc_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym _bfd_sparc_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections \ -- _bfd_sparc_elf_size_dynamic_sections -+#define elf_backend_late_size_sections _bfd_sparc_elf_late_size_sections - #define elf_backend_relocate_section _bfd_sparc_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ - _bfd_sparc_elf_finish_dynamic_symbol ---- a/bfd/elf32-tic6x.c -+++ b/bfd/elf32-tic6x.c -@@ -3160,7 +3160,7 @@ elf32_tic6x_allocate_dynrelocs (struct e - /* Set the sizes of the dynamic sections. */ - - static bool --elf32_tic6x_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf32_tic6x_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct elf32_tic6x_link_hash_table *htab; - bfd *dynobj; -@@ -3171,7 +3171,7 @@ elf32_tic6x_size_dynamic_sections (bfd * - htab = elf32_tic6x_hash_table (info); - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -3358,7 +3358,7 @@ elf32_tic6x_size_dynamic_sections (bfd * - and the input sections have been assigned to output sections. */ - - static bool --elf32_tic6x_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf32_tic6x_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - if (elf32_tic6x_using_dsbt (output_bfd) && !bfd_link_relocatable (info) - && !bfd_elf_stack_segment_size (output_bfd, info, -@@ -4261,10 +4261,10 @@ elf32_tic6x_write_section (bfd *output_b - #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible - #define elf_backend_finish_dynamic_symbol \ - elf32_tic6x_finish_dynamic_symbol --#define elf_backend_always_size_sections \ -- elf32_tic6x_always_size_sections --#define elf_backend_size_dynamic_sections \ -- elf32_tic6x_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ elf32_tic6x_early_size_sections -+#define elf_backend_late_size_sections \ -+ elf32_tic6x_late_size_sections - #define elf_backend_finish_dynamic_sections \ - elf32_tic6x_finish_dynamic_sections - #define bfd_elf32_bfd_final_link \ ---- a/bfd/elf32-tilegx.c -+++ b/bfd/elf32-tilegx.c -@@ -105,7 +105,7 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_I - #define elf_backend_check_relocs tilegx_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol tilegx_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym tilegx_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections tilegx_elf_size_dynamic_sections -+#define elf_backend_late_size_sections tilegx_elf_late_size_sections - #define elf_backend_relocate_section tilegx_elf_relocate_section - #define elf_backend_finish_dynamic_symbol tilegx_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections tilegx_elf_finish_dynamic_sections ---- a/bfd/elf32-tilepro.c -+++ b/bfd/elf32-tilepro.c -@@ -2182,11 +2182,9 @@ tilepro_elf_omit_section_dynsym (bfd *ou - #define ELF32_DYNAMIC_INTERPRETER "/lib/ld.so.1" - - static bool --tilepro_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+tilepro_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { -- (void)output_bfd; -- - struct elf_link_hash_table *htab; - bfd *dynobj; - asection *s; -@@ -2195,7 +2193,8 @@ tilepro_elf_size_dynamic_sections (bfd * - htab = tilepro_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -3739,7 +3738,7 @@ tilepro_additional_program_headers (bfd - #define elf_backend_check_relocs tilepro_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol tilepro_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym tilepro_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections tilepro_elf_size_dynamic_sections -+#define elf_backend_late_size_sections tilepro_elf_late_size_sections - #define elf_backend_relocate_section tilepro_elf_relocate_section - #define elf_backend_finish_dynamic_symbol tilepro_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections tilepro_elf_finish_dynamic_sections ---- a/bfd/elf32-vax.c -+++ b/bfd/elf32-vax.c -@@ -36,7 +36,6 @@ static bool elf_vax_check_relocs (bfd *, - asection *, const Elf_Internal_Rela *); - static bool elf_vax_adjust_dynamic_symbol (struct bfd_link_info *, - struct elf_link_hash_entry *); --static bool elf_vax_size_dynamic_sections (bfd *, struct bfd_link_info *); - static int elf_vax_relocate_section (bfd *, struct bfd_link_info *, - bfd *, asection *, bfd_byte *, - Elf_Internal_Rela *, -@@ -985,8 +984,8 @@ elf_vax_discard_got_entries (struct elf_ - /* Discard unused dynamic data if this is a static link. */ - - static bool --elf_vax_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_vax_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -1024,14 +1023,15 @@ elf_vax_always_size_sections (bfd *outpu - /* Set the sizes of the dynamic sections. */ - - static bool --elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf_vax_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; - bool relocs; - - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -1861,10 +1861,8 @@ elf_vax_plt_sym_val (bfd_vma i, const as - #define elf_backend_check_relocs elf_vax_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - elf_vax_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- elf_vax_always_size_sections --#define elf_backend_size_dynamic_sections \ -- elf_vax_size_dynamic_sections -+#define elf_backend_early_size_sections elf_vax_early_size_sections -+#define elf_backend_late_size_sections elf_vax_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section elf_vax_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf32-xstormy16.c -+++ b/bfd/elf32-xstormy16.c -@@ -706,8 +706,8 @@ xstormy16_elf_relax_section (bfd *dynobj - } - - static bool --xstormy16_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+xstormy16_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *splt; -@@ -1013,8 +1013,8 @@ xstormy16_elf_gc_mark_hook (asection *se - #define elf_backend_relocate_section xstormy16_elf_relocate_section - #define elf_backend_gc_mark_hook xstormy16_elf_gc_mark_hook - #define elf_backend_check_relocs xstormy16_elf_check_relocs --#define elf_backend_always_size_sections \ -- xstormy16_elf_always_size_sections -+#define elf_backend_early_size_sections \ -+ xstormy16_elf_early_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_finish_dynamic_sections \ ---- a/bfd/elf32-xtensa.c -+++ b/bfd/elf32-xtensa.c -@@ -1557,8 +1557,8 @@ elf_xtensa_allocate_local_got_size (stru - /* Set the sizes of the dynamic sections. */ - - static bool --elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_xtensa_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_xtensa_link_hash_table *htab; - bfd *dynobj, *abfd; -@@ -1575,7 +1575,7 @@ elf_xtensa_size_dynamic_sections (bfd *o - - dynobj = elf_hash_table (info)->dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - srelgot = htab->elf.srelgot; - srelplt = htab->elf.srelplt; - -@@ -1780,8 +1780,7 @@ elf_xtensa_size_dynamic_sections (bfd *o - } - - static bool --elf_xtensa_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf_xtensa_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct elf_xtensa_link_hash_table *htab; - asection *tls_sec; -@@ -11544,8 +11543,8 @@ static const struct bfd_elf_special_sect - #define elf_backend_object_p elf_xtensa_object_p - #define elf_backend_reloc_type_class elf_xtensa_reloc_type_class - #define elf_backend_relocate_section elf_xtensa_relocate_section --#define elf_backend_size_dynamic_sections elf_xtensa_size_dynamic_sections --#define elf_backend_always_size_sections elf_xtensa_always_size_sections -+#define elf_backend_late_size_sections elf_xtensa_late_size_sections -+#define elf_backend_early_size_sections elf_xtensa_early_size_sections - #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all - #define elf_backend_special_sections elf_xtensa_special_sections - #define elf_backend_action_discarded elf_xtensa_action_discarded ---- a/bfd/elf64-alpha.c -+++ b/bfd/elf64-alpha.c -@@ -2562,8 +2562,8 @@ elf64_alpha_size_plt_section (struct bfd - } - - static bool --elf64_alpha_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf64_alpha_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *i; - struct alpha_elf_link_hash_table * htab; -@@ -2789,8 +2789,8 @@ elf64_alpha_size_rela_got_section (struc - /* Set the sizes of the dynamic sections. */ - - static bool --elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf64_alpha_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s; -@@ -2802,7 +2802,8 @@ elf64_alpha_size_dynamic_sections (bfd * - return false; - - dynobj = elf_hash_table(info)->dynobj; -- BFD_ASSERT(dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5448,10 +5449,10 @@ static const struct elf_size_info alpha_ - elf64_alpha_merge_symbol_attribute - #define elf_backend_copy_indirect_symbol \ - elf64_alpha_copy_indirect_symbol --#define elf_backend_always_size_sections \ -- elf64_alpha_always_size_sections --#define elf_backend_size_dynamic_sections \ -- elf64_alpha_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ elf64_alpha_early_size_sections -+#define elf_backend_late_size_sections \ -+ elf64_alpha_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_relocate_section \ ---- a/bfd/elf64-hppa.c -+++ b/bfd/elf64-hppa.c -@@ -176,9 +176,6 @@ static bool elf64_hppa_adjust_dynamic_sy - static bool elf64_hppa_mark_milli_and_exported_functions - (struct elf_link_hash_entry *, void *); - --static bool elf64_hppa_size_dynamic_sections -- (bfd *, struct bfd_link_info *); -- - static int elf64_hppa_link_output_symbol_hook - (struct bfd_link_info *, const char *, Elf_Internal_Sym *, - asection *, struct elf_link_hash_entry *); -@@ -1520,7 +1517,7 @@ elf64_hppa_mark_milli_and_exported_funct - the contents of our special sections. */ - - static bool --elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+elf64_hppa_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct elf64_hppa_link_hash_table *hppa_info; - struct elf64_hppa_allocate_data data; -@@ -1534,7 +1531,8 @@ elf64_hppa_size_dynamic_sections (bfd *o - return false; - - dynobj = hppa_info->root.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - /* Mark each function this program exports so that we will allocate - space in the .opd section for each function's FPTR. If we are -@@ -3984,8 +3982,7 @@ const struct elf_size_info hppa64_elf_si - #define elf_backend_adjust_dynamic_symbol \ - elf64_hppa_adjust_dynamic_symbol - --#define elf_backend_size_dynamic_sections \ -- elf64_hppa_size_dynamic_sections -+#define elf_backend_late_size_sections elf64_hppa_late_size_sections - - #define elf_backend_finish_dynamic_symbol \ - elf64_hppa_finish_dynamic_symbol ---- a/bfd/elf64-ia64-vms.c -+++ b/bfd/elf64-ia64-vms.c -@@ -2591,8 +2591,8 @@ elf64_ia64_adjust_dynamic_symbol (struct - } - - static bool --elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf64_ia64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf64_ia64_allocate_data data; - struct elf64_ia64_link_hash_table *ia64_info; -@@ -2601,11 +2601,12 @@ elf64_ia64_size_dynamic_sections (bfd *o - struct elf_link_hash_table *hash_table; - - hash_table = elf_hash_table (info); -- dynobj = hash_table->dynobj; - ia64_info = elf64_ia64_hash_table (info); - if (ia64_info == NULL) - return false; -- BFD_ASSERT(dynobj != NULL); -+ dynobj = hash_table->dynobj; -+ if (dynobj == NULL) -+ return true; - data.info = info; - - /* Allocate the GOT entries. */ -@@ -5485,8 +5486,8 @@ static const struct elf_size_info elf64_ - elf64_ia64_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - elf64_ia64_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- elf64_ia64_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elf64_ia64_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_relocate_section \ ---- a/bfd/elf64-mips.c -+++ b/bfd/elf64-mips.c -@@ -4748,10 +4748,10 @@ const struct elf_size_info mips_elf64_si - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_mips_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_mips_elf_size_dynamic_sections -+#define elf_backend_early_size_sections \ -+ _bfd_mips_elf_early_size_sections -+#define elf_backend_late_size_sections \ -+ _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf64-ppc.c -+++ b/bfd/elf64-ppc.c -@@ -119,8 +119,8 @@ static bfd_vma opd_entry_value - #define elf_backend_adjust_dynamic_symbol ppc64_elf_adjust_dynamic_symbol - #define elf_backend_hide_symbol ppc64_elf_hide_symbol - #define elf_backend_maybe_function_sym ppc64_elf_maybe_function_sym --#define elf_backend_always_size_sections ppc64_elf_edit --#define elf_backend_size_dynamic_sections ppc64_elf_size_dynamic_sections -+#define elf_backend_early_size_sections ppc64_elf_edit -+#define elf_backend_late_size_sections ppc64_elf_late_size_sections - #define elf_backend_hash_symbol ppc64_elf_hash_symbol - #define elf_backend_init_index_section _bfd_elf_init_2_index_sections - #define elf_backend_action_discarded ppc64_elf_action_discarded -@@ -10138,7 +10138,7 @@ allocate_dynrelocs (struct elf_link_hash - ((((v) & 0x3ffff0000ULL) << 16) | (v & 0xffff)) - #define HA34(v) ((v + (1ULL << 33)) >> 34) - --/* Called via elf_link_hash_traverse from ppc64_elf_size_dynamic_sections -+/* Called via elf_link_hash_traverse from ppc64_elf_late_size_sections - to set up space for global entry stubs. These are put in glink, - after the branch table. */ - -@@ -10215,8 +10215,8 @@ size_global_entry_stubs (struct elf_link - /* Set the sizes of the dynamic sections. */ - - static bool --ppc64_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+ppc64_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct ppc_link_hash_table *htab; - bfd *dynobj; -@@ -10231,7 +10231,7 @@ ppc64_elf_size_dynamic_sections (bfd *ou - - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { ---- a/bfd/elf64-s390.c -+++ b/bfd/elf64-s390.c -@@ -1301,7 +1301,7 @@ elf_s390_gc_mark_hook (asection *sec, - entry but we found we will not create any. Called when we find we will - not have any PLT for this symbol, by for example - elf_s390_adjust_dynamic_symbol when we're doing a proper dynamic link, -- or elf_s390_size_dynamic_sections if no dynamic sections will be -+ or elf_s390_late_size_sections if no dynamic sections will be - created (we're only linking static objects). */ - - static void -@@ -1714,8 +1714,8 @@ allocate_dynrelocs (struct elf_link_hash - /* Set the sizes of the dynamic sections. */ - - static bool --elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_s390_link_hash_table *htab; - bfd *dynobj; -@@ -1729,7 +1729,7 @@ elf_s390_size_dynamic_sections (bfd *out - - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -3912,7 +3912,7 @@ const struct elf_size_info s390_elf64_si - #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook - #define elf_backend_reloc_type_class elf_s390_reloc_type_class - #define elf_backend_relocate_section elf_s390_relocate_section --#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections -+#define elf_backend_late_size_sections elf_s390_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_grok_prstatus elf_s390_grok_prstatus - #define elf_backend_grok_psinfo elf_s390_grok_psinfo ---- a/bfd/elf64-sparc.c -+++ b/bfd/elf64-sparc.c -@@ -953,8 +953,8 @@ const struct elf_size_info elf64_sparc_s - _bfd_sparc_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym \ - _bfd_sparc_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections \ -- _bfd_sparc_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_sparc_elf_late_size_sections - #define elf_backend_relocate_section \ - _bfd_sparc_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elf64-tilegx.c -+++ b/bfd/elf64-tilegx.c -@@ -106,7 +106,7 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_I - #define elf_backend_check_relocs tilegx_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol tilegx_elf_adjust_dynamic_symbol - #define elf_backend_omit_section_dynsym tilegx_elf_omit_section_dynsym --#define elf_backend_size_dynamic_sections tilegx_elf_size_dynamic_sections -+#define elf_backend_late_size_sections tilegx_elf_late_size_sections - #define elf_backend_relocate_section tilegx_elf_relocate_section - #define elf_backend_finish_dynamic_symbol tilegx_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections tilegx_elf_finish_dynamic_sections ---- a/bfd/elf64-x86-64.c -+++ b/bfd/elf64-x86-64.c -@@ -2468,8 +2468,7 @@ elf_x86_64_scan_relocs (bfd *abfd, struc - } - - static bool --elf_x86_64_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elf_x86_64_early_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - bfd *abfd; - -@@ -2482,7 +2481,7 @@ elf_x86_64_always_size_sections (bfd *ou - elf_x86_64_scan_relocs)) - return false; - -- return _bfd_x86_elf_always_size_sections (output_bfd, info); -+ return _bfd_x86_elf_early_size_sections (output_bfd, info); - } - - /* Return the relocation value for @tpoff relocation -@@ -5413,7 +5412,7 @@ elf_x86_64_special_sections[]= - elf_x86_64_reloc_name_lookup - - #define elf_backend_relocs_compatible elf_x86_64_relocs_compatible --#define elf_backend_always_size_sections elf_x86_64_always_size_sections -+#define elf_backend_early_size_sections elf_x86_64_early_size_sections - #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections - #define elf_backend_finish_dynamic_sections elf_x86_64_finish_dynamic_sections - #define elf_backend_finish_dynamic_symbol elf_x86_64_finish_dynamic_symbol ---- a/bfd/elflink.c -+++ b/bfd/elflink.c -@@ -6648,8 +6648,8 @@ bfd_elf_size_dynamic_sections (bfd *outp - - /* The backend may have to create some sections regardless of whether - we're dynamic or not. */ -- if (bed->elf_backend_always_size_sections -- && ! (*bed->elf_backend_always_size_sections) (output_bfd, info)) -+ if (bed->elf_backend_early_size_sections -+ && !bed->elf_backend_early_size_sections (output_bfd, info)) - return false; - - dynobj = elf_hash_table (info)->dynobj; -@@ -7429,9 +7429,8 @@ NOTE: This behaviour is deprecated and w - - /* The backend must work out the sizes of all the other dynamic - sections. */ -- if (dynobj != NULL -- && bed->elf_backend_size_dynamic_sections != NULL -- && ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info)) -+ if (bed->elf_backend_late_size_sections != NULL -+ && !bed->elf_backend_late_size_sections (output_bfd, info)) - return false; - - if (dynobj != NULL && elf_hash_table (info)->dynamic_sections_created) ---- a/bfd/elfn32-mips.c -+++ b/bfd/elfn32-mips.c -@@ -4138,10 +4138,8 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_always_size_sections \ -- _bfd_mips_elf_always_size_sections --#define elf_backend_size_dynamic_sections \ -- _bfd_mips_elf_size_dynamic_sections -+#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections -+#define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section - #define elf_backend_finish_dynamic_symbol \ ---- a/bfd/elfnn-aarch64.c -+++ b/bfd/elfnn-aarch64.c -@@ -112,7 +112,7 @@ - allocate space for one relocation on the slot. Record the GOT offset - for this symbol. - -- elfNN_aarch64_size_dynamic_sections () -+ elfNN_aarch64_late_size_sections () - - Iterate all input BFDS, look for in the local symbol data structure - constructed earlier for local TLS symbols and allocate them double -@@ -9144,8 +9144,8 @@ elfNN_aarch64_allocate_local_ifunc_dynre - though ! */ - - static bool --elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elfNN_aarch64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elf_aarch64_link_hash_table *htab; - bfd *dynobj; -@@ -9156,7 +9156,8 @@ elfNN_aarch64_size_dynamic_sections (bfd - htab = elf_aarch64_hash_table ((info)); - dynobj = htab->root.dynobj; - -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->root.dynamic_sections_created) - { -@@ -9558,8 +9559,8 @@ elfNN_aarch64_create_small_pltn_entry (s - _TLS_MODULE_BASE_, if needed. */ - - static bool --elfNN_aarch64_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+elfNN_aarch64_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - asection *tls_sec; - -@@ -10292,8 +10293,8 @@ const struct elf_size_info elfNN_aarch64 - #define elf_backend_adjust_dynamic_symbol \ - elfNN_aarch64_adjust_dynamic_symbol - --#define elf_backend_always_size_sections \ -- elfNN_aarch64_always_size_sections -+#define elf_backend_early_size_sections \ -+ elfNN_aarch64_early_size_sections - - #define elf_backend_check_relocs \ - elfNN_aarch64_check_relocs -@@ -10348,8 +10349,8 @@ const struct elf_size_info elfNN_aarch64 - #define elf_backend_modify_headers \ - elfNN_aarch64_modify_headers - --#define elf_backend_size_dynamic_sections \ -- elfNN_aarch64_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elfNN_aarch64_late_size_sections - - #define elf_backend_size_info \ - elfNN_aarch64_size_info ---- a/bfd/elfnn-ia64.c -+++ b/bfd/elfnn-ia64.c -@@ -2987,8 +2987,8 @@ elfNN_ia64_adjust_dynamic_symbol (struct - } - - static bool --elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+elfNN_ia64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct elfNN_ia64_allocate_data data; - struct elfNN_ia64_link_hash_table *ia64_info; -@@ -2999,8 +2999,9 @@ elfNN_ia64_size_dynamic_sections (bfd *o - if (ia64_info == NULL) - return false; - dynobj = ia64_info->root.dynobj; -+ if (dynobj == NULL) -+ return true; - ia64_info->self_dtpmod_offset = (bfd_vma) -1; -- BFD_ASSERT(dynobj != NULL); - data.info = info; - - /* Set the contents of the .interp section to the interpreter. */ -@@ -5036,8 +5037,8 @@ ignore_errors (const char *fmt ATTRIBUTE - elfNN_ia64_check_relocs - #define elf_backend_adjust_dynamic_symbol \ - elfNN_ia64_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections \ -- elfNN_ia64_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ elfNN_ia64_late_size_sections - #define elf_backend_omit_section_dynsym \ - _bfd_elf_omit_section_dynsym_all - #define elf_backend_relocate_section \ ---- a/bfd/elfnn-loongarch.c -+++ b/bfd/elfnn-loongarch.c -@@ -1581,8 +1581,8 @@ maybe_set_textrel (struct elf_link_hash_ - } - - static bool --loongarch_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+loongarch_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct loongarch_elf_link_hash_table *htab; - bfd *dynobj; -@@ -1592,7 +1592,8 @@ loongarch_elf_size_dynamic_sections (bfd - htab = loongarch_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (htab->elf.dynamic_sections_created) - { -@@ -4651,7 +4652,7 @@ elf_loongarch64_hash_symbol (struct elf_ - loongarch_elf_create_dynamic_sections - #define elf_backend_check_relocs loongarch_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol loongarch_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections loongarch_elf_size_dynamic_sections -+#define elf_backend_late_size_sections loongarch_elf_late_size_sections - #define elf_backend_relocate_section loongarch_elf_relocate_section - #define elf_backend_finish_dynamic_symbol loongarch_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections \ ---- a/bfd/elfnn-riscv.c -+++ b/bfd/elfnn-riscv.c -@@ -1485,7 +1485,7 @@ allocate_local_ifunc_dynrelocs (void **s - } - - static bool --riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+riscv_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info) - { - struct riscv_elf_link_hash_table *htab; - bfd *dynobj; -@@ -1495,7 +1495,8 @@ riscv_elf_size_dynamic_sections (bfd *ou - htab = riscv_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -5540,7 +5541,7 @@ riscv_elf_merge_symbol_attribute (struct - #define elf_backend_create_dynamic_sections riscv_elf_create_dynamic_sections - #define elf_backend_check_relocs riscv_elf_check_relocs - #define elf_backend_adjust_dynamic_symbol riscv_elf_adjust_dynamic_symbol --#define elf_backend_size_dynamic_sections riscv_elf_size_dynamic_sections -+#define elf_backend_late_size_sections riscv_elf_late_size_sections - #define elf_backend_relocate_section riscv_elf_relocate_section - #define elf_backend_finish_dynamic_symbol riscv_elf_finish_dynamic_symbol - #define elf_backend_finish_dynamic_sections riscv_elf_finish_dynamic_sections ---- a/bfd/elfxx-mips.c -+++ b/bfd/elfxx-mips.c -@@ -9644,8 +9644,8 @@ _bfd_mips_elf_adjust_dynamic_symbol (str - check for any mips16 stub sections that we can discard. */ - - bool --_bfd_mips_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_mips_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - asection *sect; - struct mips_elf_link_hash_table *htab; -@@ -9988,8 +9988,8 @@ mips_elf_set_plt_sym_value (struct mips_ - /* Set the sizes of the dynamic sections. */ - - bool --_bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_mips_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - bfd *dynobj; - asection *s, *sreldyn; -@@ -9999,7 +9999,8 @@ _bfd_mips_elf_size_dynamic_sections (bfd - htab = mips_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = elf_hash_table (info)->dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { -@@ -14933,7 +14934,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_always_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_early_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf_External_ABIFlags_v0)); - - /* Skip this section later on (I don't think this currently -@@ -14992,7 +14993,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_always_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_early_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf32_External_RegInfo)); - - /* Skip this section later on (I don't think this currently ---- a/bfd/elfxx-mips.h -+++ b/bfd/elfxx-mips.h -@@ -67,9 +67,9 @@ extern bool _bfd_mips_elf_check_relocs - (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); - extern bool _bfd_mips_elf_adjust_dynamic_symbol - (struct bfd_link_info *, struct elf_link_hash_entry *); --extern bool _bfd_mips_elf_always_size_sections -+extern bool _bfd_mips_elf_early_size_sections - (bfd *, struct bfd_link_info *); --extern bool _bfd_mips_elf_size_dynamic_sections -+extern bool _bfd_mips_elf_late_size_sections - (bfd *, struct bfd_link_info *); - extern int _bfd_mips_elf_relocate_section - (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, ---- a/bfd/elfxx-sparc.c -+++ b/bfd/elfxx-sparc.c -@@ -2381,8 +2381,8 @@ _bfd_sparc_elf_omit_section_dynsym (bfd - /* Set the sizes of the dynamic sections. */ - - bool --_bfd_sparc_elf_size_dynamic_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_sparc_elf_late_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - struct _bfd_sparc_elf_link_hash_table *htab; - bfd *dynobj; -@@ -2392,7 +2392,8 @@ _bfd_sparc_elf_size_dynamic_sections (bf - htab = _bfd_sparc_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { ---- a/bfd/elfxx-sparc.h -+++ b/bfd/elfxx-sparc.h -@@ -117,7 +117,7 @@ extern bool _bfd_sparc_elf_adjust_dynami - (struct bfd_link_info *, struct elf_link_hash_entry *); - extern bool _bfd_sparc_elf_omit_section_dynsym - (bfd *, struct bfd_link_info *, asection *); --extern bool _bfd_sparc_elf_size_dynamic_sections -+extern bool _bfd_sparc_elf_late_size_sections - (bfd *, struct bfd_link_info *); - extern bool _bfd_sparc_elf_new_section_hook - (bfd *, asection *); ---- a/bfd/elfxx-target.h -+++ b/bfd/elfxx-target.h -@@ -487,11 +487,11 @@ - #ifndef elf_backend_adjust_dynamic_symbol - #define elf_backend_adjust_dynamic_symbol 0 - #endif --#ifndef elf_backend_always_size_sections --#define elf_backend_always_size_sections 0 -+#ifndef elf_backend_early_size_sections -+#define elf_backend_early_size_sections 0 - #endif --#ifndef elf_backend_size_dynamic_sections --#define elf_backend_size_dynamic_sections 0 -+#ifndef elf_backend_late_size_sections -+#define elf_backend_late_size_sections 0 - #endif - #ifndef elf_backend_strip_zero_sized_dynamic_sections - #define elf_backend_strip_zero_sized_dynamic_sections 0 -@@ -849,8 +849,8 @@ static const struct elf_backend_data elf - elf_backend_check_directives, - elf_backend_notice_as_needed, - elf_backend_adjust_dynamic_symbol, -- elf_backend_always_size_sections, -- elf_backend_size_dynamic_sections, -+ elf_backend_early_size_sections, -+ elf_backend_late_size_sections, - elf_backend_strip_zero_sized_dynamic_sections, - elf_backend_init_index_section, - elf_backend_relocate_section, ---- a/bfd/elfxx-tilegx.c -+++ b/bfd/elfxx-tilegx.c -@@ -2430,8 +2430,8 @@ tilegx_elf_omit_section_dynsym (bfd *out - } - - bool --tilegx_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info) -+tilegx_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) - { - struct tilegx_elf_link_hash_table *htab; - bfd *dynobj; -@@ -2441,7 +2441,8 @@ tilegx_elf_size_dynamic_sections (bfd *o - htab = tilegx_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - dynobj = htab->elf.dynobj; -- BFD_ASSERT (dynobj != NULL); -+ if (dynobj == NULL) -+ return true; - - if (elf_hash_table (info)->dynamic_sections_created) - { ---- a/bfd/elfxx-tilegx.h -+++ b/bfd/elfxx-tilegx.h -@@ -57,7 +57,7 @@ tilegx_elf_omit_section_dynsym (bfd *, - asection *); - - extern bool --tilegx_elf_size_dynamic_sections (bfd *, struct bfd_link_info *); -+tilegx_elf_late_size_sections (bfd *, struct bfd_link_info *); - - extern int - tilegx_elf_relocate_section (bfd *, struct bfd_link_info *, ---- a/bfd/elfxx-x86.c -+++ b/bfd/elfxx-x86.c -@@ -2241,7 +2241,7 @@ _bfd_elf_x86_valid_reloc_p (asection *in - /* Set the sizes of the dynamic sections. */ - - bool --_bfd_x86_elf_size_dynamic_sections (bfd *output_bfd, -+_bfd_x86_elf_late_size_sections (bfd *output_bfd, - struct bfd_link_info *info) - { - struct elf_x86_link_hash_table *htab; -@@ -2257,7 +2257,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd - return false; - dynobj = htab->elf.dynobj; - if (dynobj == NULL) -- abort (); -+ return true; - - /* Set up .got offsets for local syms, and space for local dynamic - relocs. */ -@@ -2964,8 +2964,8 @@ _bfd_x86_elf_finish_dynamic_sections (bf - - - bool --_bfd_x86_elf_always_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) -+_bfd_x86_elf_early_size_sections (bfd *output_bfd, -+ struct bfd_link_info *info) - { - asection *tls_sec = elf_hash_table (info)->tls_sec; - ---- a/bfd/elfxx-x86.h -+++ b/bfd/elfxx-x86.h -@@ -847,13 +847,13 @@ extern bool _bfd_elf_x86_valid_reloc_p - const Elf_Internal_Rela *, struct elf_link_hash_entry *, - Elf_Internal_Sym *, Elf_Internal_Shdr *, bool *); - --extern bool _bfd_x86_elf_size_dynamic_sections -+extern bool _bfd_x86_elf_late_size_sections - (bfd *, struct bfd_link_info *); - - extern struct elf_x86_link_hash_table *_bfd_x86_elf_finish_dynamic_sections - (bfd *, struct bfd_link_info *); - --extern bool _bfd_x86_elf_always_size_sections -+extern bool _bfd_x86_elf_early_size_sections - (bfd *, struct bfd_link_info *); - - extern void _bfd_x86_elf_merge_symbol_attribute -@@ -925,8 +925,8 @@ extern void _bfd_x86_elf_link_report_rel - - #define elf_backend_check_relocs \ - _bfd_x86_elf_check_relocs --#define elf_backend_size_dynamic_sections \ -- _bfd_x86_elf_size_dynamic_sections -+#define elf_backend_late_size_sections \ -+ _bfd_x86_elf_late_size_sections - #define elf_backend_merge_symbol_attribute \ - _bfd_x86_elf_merge_symbol_attribute - #define elf_backend_copy_indirect_symbol \ ---- a/ld/emultempl/vms.em -+++ b/ld/emultempl/vms.em -@@ -196,10 +196,9 @@ gld${EMULATION_NAME}_before_allocation ( - - /* The backend must work out the sizes of all the other dynamic - sections. */ -- if (elf_hash_table (&link_info)->dynamic_sections_created -- && bed->elf_backend_size_dynamic_sections -- && ! (*bed->elf_backend_size_dynamic_sections) (link_info.output_bfd, -- &link_info)) -+ if (bed->elf_backend_late_size_sections -+ && !bed->elf_backend_late_size_sections (link_info.output_bfd, -+ &link_info)) - einfo (_("%F%P: failed to set dynamic section sizes: %E\n")); - - before_allocation_default (); diff --git a/toolchain/binutils/patches/2.41/002-PR-30569-delete-_bfd_mips_elf_early_size_sections.patch b/toolchain/binutils/patches/2.41/002-PR-30569-delete-_bfd_mips_elf_early_size_sections.patch deleted file mode 100644 index 6d47db5f2e..0000000000 --- a/toolchain/binutils/patches/2.41/002-PR-30569-delete-_bfd_mips_elf_early_size_sections.patch +++ /dev/null @@ -1,218 +0,0 @@ -From 3c6c32951e292a51ede70b8087bb0308d7dbc4fc Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Thu, 28 Mar 2024 20:33:32 +1030 -Subject: [PATCH 2/2] PR 30569, delete _bfd_mips_elf_early_size_sections - -PR30569 was triggered by a patch of mine 6540edd52cc0 moving the call -to always_size_sections in bfd_elf_size_dynamic_sections earlier, made -to support the x86 DT_RELR implementation. This broke mips16 code -handling stubs when --export-dynamic is passed to the linker, because -numerous symbols then became dynamic after always_size_sections. The -mips backend fiddles with symbols in its always_size_sections. Maciej -in 902e9fc76a0e had moved the call to always_size_sections to after -the export-dynamic code. Prior to that, Nathan in 04c3a75556c0 moved -it before the exec stack code, back to the start of -bfd_elf_size_dynamic_sections which was where Ian put it originally -in ff12f303355b. So the call has moved around a little. I'm leaving -it where it is, and instead calling mips_elf_check_symbols from -late_size_sections (the old size_dynamic_sections) which is now always -called. In fact, the whole of _bfd_mips_elf_early_size_sections can -be merged into _bfd_mips_elf_late_size_sections. ---- - bfd/elf32-mips.c | 1 - - bfd/elf64-mips.c | 2 -- - bfd/elfn32-mips.c | 1 - - bfd/elfxx-mips.c | 84 +++++++++++++++++++---------------------------- - bfd/elfxx-mips.h | 2 -- - 5 files changed, 34 insertions(+), 56 deletions(-) - ---- a/bfd/elf32-mips.c -+++ b/bfd/elf32-mips.c -@@ -2537,7 +2537,6 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections - #define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section ---- a/bfd/elf64-mips.c -+++ b/bfd/elf64-mips.c -@@ -4748,8 +4748,6 @@ const struct elf_size_info mips_elf64_si - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_early_size_sections \ -- _bfd_mips_elf_early_size_sections - #define elf_backend_late_size_sections \ - _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section ---- a/bfd/elfn32-mips.c -+++ b/bfd/elfn32-mips.c -@@ -4138,7 +4138,6 @@ static const struct ecoff_debug_swap mip - #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag - #define elf_backend_adjust_dynamic_symbol \ - _bfd_mips_elf_adjust_dynamic_symbol --#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections - #define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections - #define elf_backend_init_index_section _bfd_elf_init_1_index_section - #define elf_backend_relocate_section _bfd_mips_elf_relocate_section ---- a/bfd/elfxx-mips.c -+++ b/bfd/elfxx-mips.c -@@ -9639,48 +9639,6 @@ _bfd_mips_elf_adjust_dynamic_symbol (str - return _bfd_elf_adjust_dynamic_copy (info, h, s); - } - --/* This function is called after all the input files have been read, -- and the input sections have been assigned to output sections. We -- check for any mips16 stub sections that we can discard. */ -- --bool --_bfd_mips_elf_early_size_sections (bfd *output_bfd, -- struct bfd_link_info *info) --{ -- asection *sect; -- struct mips_elf_link_hash_table *htab; -- struct mips_htab_traverse_info hti; -- -- htab = mips_elf_hash_table (info); -- BFD_ASSERT (htab != NULL); -- -- /* The .reginfo section has a fixed size. */ -- sect = bfd_get_section_by_name (output_bfd, ".reginfo"); -- if (sect != NULL) -- { -- bfd_set_section_size (sect, sizeof (Elf32_External_RegInfo)); -- sect->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -- } -- -- /* The .MIPS.abiflags section has a fixed size. */ -- sect = bfd_get_section_by_name (output_bfd, ".MIPS.abiflags"); -- if (sect != NULL) -- { -- bfd_set_section_size (sect, sizeof (Elf_External_ABIFlags_v0)); -- sect->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -- } -- -- hti.info = info; -- hti.output_bfd = output_bfd; -- hti.error = false; -- mips_elf_link_hash_traverse (mips_elf_hash_table (info), -- mips_elf_check_symbols, &hti); -- if (hti.error) -- return false; -- -- return true; --} -- - /* If the link uses a GOT, lay it out and work out its size. */ - - static bool -@@ -9985,7 +9943,8 @@ mips_elf_set_plt_sym_value (struct mips_ - return true; - } - --/* Set the sizes of the dynamic sections. */ -+/* Set the sizes of the dynamic sections, some mips non-dynamic sections, -+ and check for any mips16 stub sections that we can discard. */ - - bool - _bfd_mips_elf_late_size_sections (bfd *output_bfd, -@@ -9995,14 +9954,39 @@ _bfd_mips_elf_late_size_sections (bfd *o - asection *s, *sreldyn; - bool reltext; - struct mips_elf_link_hash_table *htab; -+ struct mips_htab_traverse_info hti; - - htab = mips_elf_hash_table (info); - BFD_ASSERT (htab != NULL); -- dynobj = elf_hash_table (info)->dynobj; -+ -+ /* The .reginfo section has a fixed size. */ -+ s = bfd_get_section_by_name (output_bfd, ".reginfo"); -+ if (s != NULL) -+ { -+ bfd_set_section_size (s, sizeof (Elf32_External_RegInfo)); -+ s->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -+ } -+ -+ /* The .MIPS.abiflags section has a fixed size. */ -+ s = bfd_get_section_by_name (output_bfd, ".MIPS.abiflags"); -+ if (s != NULL) -+ { -+ bfd_set_section_size (s, sizeof (Elf_External_ABIFlags_v0)); -+ s->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; -+ } -+ -+ hti.info = info; -+ hti.output_bfd = output_bfd; -+ hti.error = false; -+ mips_elf_link_hash_traverse (htab, mips_elf_check_symbols, &hti); -+ if (hti.error) -+ return false; -+ -+ dynobj = htab->root.dynobj; - if (dynobj == NULL) - return true; - -- if (elf_hash_table (info)->dynamic_sections_created) -+ if (htab->root.dynamic_sections_created) - { - /* Set the contents of the .interp section to the interpreter. */ - if (bfd_link_executable (info) && !info->nointerp) -@@ -10142,7 +10126,7 @@ _bfd_mips_elf_late_size_sections (bfd *o - } - } - else if (bfd_link_executable (info) -- && ! mips_elf_hash_table (info)->use_rld_obj_head -+ && !htab->use_rld_obj_head - && startswith (name, ".rld_map")) - { - /* We add a room for __rld_map. It will be filled in by the -@@ -10151,7 +10135,7 @@ _bfd_mips_elf_late_size_sections (bfd *o - } - else if (SGI_COMPAT (output_bfd) - && startswith (name, ".compact_rel")) -- s->size += mips_elf_hash_table (info)->compact_rel_size; -+ s->size += htab->compact_rel_size; - else if (s == htab->root.splt) - { - /* If the last PLT entry has a branch delay slot, allocate -@@ -10191,7 +10175,7 @@ _bfd_mips_elf_late_size_sections (bfd *o - } - } - -- if (elf_hash_table (info)->dynamic_sections_created) -+ if (htab->root.dynamic_sections_created) - { - /* Add some entries to the .dynamic section. We fill in the - values later, in _bfd_mips_elf_finish_dynamic_sections, but we -@@ -14934,7 +14918,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_early_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_late_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf_External_ABIFlags_v0)); - - /* Skip this section later on (I don't think this currently -@@ -14993,7 +14977,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str - input_section->flags &= ~SEC_HAS_CONTENTS; - } - -- /* Size has been set in _bfd_mips_elf_early_size_sections. */ -+ /* Size has been set in _bfd_mips_elf_late_size_sections. */ - BFD_ASSERT(o->size == sizeof (Elf32_External_RegInfo)); - - /* Skip this section later on (I don't think this currently ---- a/bfd/elfxx-mips.h -+++ b/bfd/elfxx-mips.h -@@ -67,8 +67,6 @@ extern bool _bfd_mips_elf_check_relocs - (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); - extern bool _bfd_mips_elf_adjust_dynamic_symbol - (struct bfd_link_info *, struct elf_link_hash_entry *); --extern bool _bfd_mips_elf_early_size_sections -- (bfd *, struct bfd_link_info *); - extern bool _bfd_mips_elf_late_size_sections - (bfd *, struct bfd_link_info *); - extern int _bfd_mips_elf_relocate_section diff --git a/toolchain/binutils/patches/2.41/300-001_ld_makefile_patch.patch b/toolchain/binutils/patches/2.41/300-001_ld_makefile_patch.patch deleted file mode 100644 index 2dafd92a01..0000000000 --- a/toolchain/binutils/patches/2.41/300-001_ld_makefile_patch.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/ld/Makefile.am -+++ b/ld/Makefile.am -@@ -50,7 +50,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) - - EMUL = @EMUL@ - EMULATION_OFILES = @EMULATION_OFILES@ ---- a/ld/Makefile.in -+++ b/ld/Makefile.in -@@ -573,7 +573,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 diff --git a/toolchain/binutils/patches/2.41/400-mips_no_dynamic_linking_sym.patch b/toolchain/binutils/patches/2.41/400-mips_no_dynamic_linking_sym.patch deleted file mode 100644 index c50a988da4..0000000000 --- a/toolchain/binutils/patches/2.41/400-mips_no_dynamic_linking_sym.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/bfd/elfxx-mips.c -+++ b/bfd/elfxx-mips.c -@@ -8144,6 +8144,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))) -@@ -8156,6 +8157,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) - { diff --git a/toolchain/binutils/patches/2.41/500-Change-default-emulation-for-mips64-linux.patch b/toolchain/binutils/patches/2.41/500-Change-default-emulation-for-mips64-linux.patch deleted file mode 100644 index 60676bbe54..0000000000 --- a/toolchain/binutils/patches/2.41/500-Change-default-emulation-for-mips64-linux.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- a/bfd/config.bfd -+++ b/bfd/config.bfd -@@ -947,8 +947,8 @@ case "${targ}" in - want64=true - ;; - 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*-gnuabi64) - targ_defvec=mips_elf64_trad_be_vec -@@ -956,8 +956,8 @@ case "${targ}" in - want64=true - ;; - 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 -@@ -585,8 +585,8 @@ mips64*el-*-linux-gnuabi64) - targ_extra_emuls="elf64btsmip elf32ltsmipn32 elf32btsmipn32 elf32ltsmip elf32btsmip" - targ_extra_libpath=$targ_extra_emuls - ;; --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-gnuabi64) -@@ -594,8 +594,8 @@ mips64*-*-linux-gnuabi64) - targ_extra_emuls="elf64ltsmip elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip" - 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 diff --git a/toolchain/gdb/Makefile b/toolchain/gdb/Makefile index ecb31398e6..9b9ee5a9d8 100644 --- a/toolchain/gdb/Makefile +++ b/toolchain/gdb/Makefile @@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gdb -PKG_VERSION:=14.1 +PKG_VERSION:=15.2 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/gdb -PKG_HASH:=d66df51276143451fcbff464cc8723d68f1e9df45a6a2d5635a54e71643edb80 +PKG_HASH:=83350ccd35b5b5a0cba6b334c41294ea968158c573940904f00b92f76345314d PKG_CPE_ID:=cpe:/a:gnu:gdb GDB_DIR:=$(PKG_NAME)-$(PKG_VERSION) diff --git a/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch index 9430509278..f9c5670094 100644 --- a/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch +++ b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch @@ -1,6 +1,6 @@ --- a/gdbserver/configure +++ b/gdbserver/configure -@@ -2674,7 +2674,7 @@ $as_echo "$as_me: error: \`$ac_var' was +@@ -2698,7 +2698,7 @@ $as_echo "$as_me: error: \`$ac_var' was ac_cache_corrupted=: ;; ,);; *)