Compare commits

..
1 Commits
Author SHA1 Message Date
Martijn Braam 71550b3335 WIP 2022-02-09 17:51:31 +01:00
2650 changed files with 83208 additions and 388721 deletions

No files matched your search

-22
View File
@@ -1,22 +0,0 @@
#!/bin/sh -e
# Description: run apkbuild-lint on modified APKBUILDs
# Options: native
# Use 'native' because it requires git commit history.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
wget "https://gitlab.com/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
sh ./install_pmbootstrap.sh
exec su "${TESTUSER:-pmos}" -c "sh -e $0"
fi
# Wrap pmbootstrap to use this repository for --aports
pmaports="$(cd "$(dirname "$0")"/..; pwd -P)"
_pmbootstrap="$(command -v pmbootstrap)"
pmbootstrap() {
"$_pmbootstrap" --aports="$pmaports" "$@"
}
.ci/lib/apkbuild_linting.py
File renamed without changes.
-1
View File
@@ -1 +0,0 @@
lib/build_changed_aports.sh
-1
View File
@@ -1 +0,0 @@
lib/build_changed_aports.sh
-1
View File
@@ -1 +0,0 @@
lib/build_changed_aports.sh
-1
View File
@@ -1 +0,0 @@
lib/build_changed_aports.sh
-1
View File
@@ -1 +0,0 @@
lib/build_changed_aports.sh
-1
View File
@@ -1 +0,0 @@
lib/build_changed_aports.sh
Executable
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh -e
# Convenience wrapper for short arch-specific build jobs in .gitlab-ci.yml
export PYTHONUNBUFFERED=1
JOB_ARCH="${CI_JOB_NAME#build-}"
set -x
su pmos -c ".ci/build_changed_aports.py $JOB_ARCH"
@@ -7,7 +7,7 @@ import sys
import common
# pmbootstrap
import add_pmbootstrap_to_import_path
import testcases.add_pmbootstrap_to_import_path
import pmb.parse
import pmb.parse._apkbuild
import pmb.helpers.pmaports
@@ -11,7 +11,7 @@ import subprocess
import common
# pmbootstrap
import add_pmbootstrap_to_import_path # noqa
import testcases.add_pmbootstrap_to_import_path # noqa
import pmb.parse
import pmb.parse.version
import pmb.helpers.logging
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2023 Oliver Smith
# Copyright 2021 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import argparse
@@ -13,7 +13,7 @@ def get_devices():
""":returns: list of all devices"""
ret = []
pmaports = (os.path.realpath(os.path.join(os.path.dirname(__file__) +
"/../..")))
"/..")))
for path in glob.glob(pmaports + "/device/*/device-*/"):
device = os.path.dirname(path).split("device-", 1)[1]
@@ -110,7 +110,7 @@ def main():
print("")
print("Now it's time to add some documentation:")
print("1) Create a device specific wiki page as described here:")
print(" https://wiki.postmarketos.org/wiki/Help:Device_Page")
print(" <https://wiki.postmarketos.org/wiki/Help:Device_Page>")
print("2) Set 'booting = yes' in the infobox of your device page.")
print("3) Run these tests again with an empty commit in your MR:")
print(" $ git commit --allow-empty -m 'run tests again'")
@@ -121,10 +121,6 @@ def main():
print("it more easily. Many times one person did a port with basic")
print("functionality, and then someone else jumped in and")
print("contributed major new features.")
print("")
print("NOTE: if you renamed a device in pmaports, rename it in the")
print("wiki as well and make sure to add it here:")
print("https://postmarketos.org/renamed")
return 1
else:
print("*** Wiki check successful!")
-20
View File
@@ -1,20 +0,0 @@
#!/bin/sh -e
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
# Description: check pkgver/pkgrel bumps, amount of changed pkgs etc
# Options: native
# Use 'native' because it requires git commit history.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
# In .gitlab-ci.yml currently .ci/pytest.sh runs before this and
# already downloads and runs install_pmbootstrap.sh.
if ! [ -e install_pmbootstrap.sh ]; then
wget "https://gitlab.com/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
sh ./install_pmbootstrap.sh
fi
exec su "${TESTUSER:-pmos}" -c "sh -e $0"
fi
.ci/lib/check_changed_aports_versions.py
+2 -10
View File
@@ -17,7 +17,7 @@ def get_pmaports_dir():
global cache
if "pmaports_dir" in cache:
return cache["pmaports_dir"]
ret = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/../.."))
ret = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
cache["pmaports_dir"] = ret
return ret
@@ -134,7 +134,7 @@ def get_changed_packages_sanity_check(count):
print("ERROR: Too many packages have changed!")
print()
print("This is a sanity check, so we don't end up building packages that")
print("have not been modified. CI won't run for more than three hours")
print("have not been modified. CI won't run for more than one hour")
print("anyway.")
print()
print("Your options:")
@@ -190,11 +190,3 @@ def get_changed_packages():
ret.add(os.path.basename(dirname))
return ret
def get_changed_kernels():
ret = []
for pkgname in get_changed_packages():
if pkgname.startswith("linux-"):
ret += [pkgname]
return ret
-13
View File
@@ -1,13 +0,0 @@
#!/bin/sh -e
# Description: editorconfig-checker: lint for trailing whitespaces etc.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add \
editorconfig-checker
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
set -x
ec
-14
View File
@@ -1,14 +0,0 @@
#!/bin/sh -e
# Description: lint CI related python scripts/tests
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add py3-flake8
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
set -x
# shellcheck disable=SC2046
flake8 --ignore E501,F401,E722,W504,W605 $(find .ci -name '*.py')
-47
View File
@@ -1,47 +0,0 @@
#!/bin/sh -e
# Description: check various bad patterns with grep
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add grep
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
# Find CHANGEMEs in APKBUILDs
if grep -qr '(CHANGEME!)' -- *; then
echo "ERROR: Please replace '(CHANGEME!)' in the following files:"
grep --color=always -r '(CHANGEME!)' -- *
exit 1
fi
# DTBs installed to /usr/share/db
# shellcheck disable=SC2016
if grep -qr 'INSTALL_DTBS_PATH="$pkgdir"/usr/share/dtb' device/; then
echo 'ERROR: Please do not install dtbs to /usr/share/dtb!'
echo 'ERROR: Unless you have a good reason not to, please put them in /boot/dtbs'
echo 'ERROR: Files that need fixing:'
# shellcheck disable=SC2016
grep --color=always -r 'INSTALL_DTBS_PATH="$pkgdir"/usr/share/dtb' device/
exit 1
fi
# Find old mkinitfs paths (pre mkinitfs 2.0)
if grep -qr '/etc/postmarketos-mkinitfs' -- *; then
echo "ERROR: Please replace '/etc/postmarketos-mkinitfs' with '/usr/share/mkinitfs' in the following files:"
grep --color=always -r '/etc/postmarketos-mkinitfs' -- *
exit 1
fi
if grep -qr '/usr/share/postmarketos-mkinitfs' -- *; then
echo "ERROR: Please replace '/usr/share/postmarketos-mkinitfs' with '/usr/share/mkinitfs' in the following files:"
grep --color=always -r '/usr/share/postmarketos-mkinitfs' -- *
exit 1
fi
# Direct sourcing of deviceinfo
if grep --exclude='source_deviceinfo' -qEr 'source /etc/deviceinfo|\. /etc/deviceinfo' -- *; then
echo 'ERROR: Please source the source_deviceinfo script instead of sourcing deviceinfo directly!'
grep --color=always --exclude='rootfs-usr-share-misc-source_deviceinfo' -Er 'source /etc/deviceinfo|\. /etc/deviceinfo' -- *
exit 1
fi
-16
View File
@@ -1,16 +0,0 @@
#!/bin/sh -e
# Description: check modified kernel configs
# Options: native
# Use 'native' because it requires running pmbootstrap.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
wget "https://gitlab.com/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
sh ./install_pmbootstrap.sh
exec su "${TESTUSER:-pmos}" -c "sh -e $0"
fi
export PYTHONUNBUFFERED=1
.ci/lib/check_changed_kernels.py
-1
View File
@@ -1 +0,0 @@
../testcases/add_pmbootstrap_to_import_path
-19
View File
@@ -1,19 +0,0 @@
#!/bin/sh -e
# Description: build modified packages for this architecture
# Options: native slow
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
wget "https://gitlab.com/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
sh ./install_pmbootstrap.sh
exec su "${TESTUSER:-pmos}" -c "sh -e $0"
fi
export PYTHONUNBUFFERED=1
# Get the architecture from the symlink we are running
arch="$(echo "$0" | cut -d '-' -f 2 | cut -d '.' -f 1)"
set -x
.ci/lib/build_changed_aports.py "$arch"
-83
View File
@@ -1,83 +0,0 @@
#!/usr/bin/env python3
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import glob
import tempfile
import sys
import subprocess
# Same dir
import common
# pmbootstrap
import add_pmbootstrap_to_import_path # noqa
import pmb.parse
import pmb.helpers.logging
def check_kconfig(args, pkgnames):
last_failed = None
for i in range(len(pkgnames)):
pkgname = pkgnames[i]
print(f" ({i+1}/{len(pkgnames)}) {pkgname}")
apkbuild_path = pmb.helpers.pmaports.find(args, pkgname)
apkbuild = pmb.parse._apkbuild.apkbuild(f"{apkbuild_path}/APKBUILD")
options = []
for opt in apkbuild["options"]:
if "pmb:kconfigcheck" in opt:
options += [opt]
if len(options):
options.sort()
print(f'options="{" ".join(options)}"')
if "!pmb:kconfigcheck" in apkbuild["options"]:
print("skipped (!pmb:kconfigcheck)")
continue
if not pmb.parse.kconfig.check(args, pkgname, details=True):
last_failed = pkgname
return last_failed
def show_error(last_failed):
print("")
print("Please adjust your kernel config. This is required for getting your"
" patch merged.")
print("")
print("Edit your kernel config:")
print(f" pmbootstrap kconfig edit {last_failed}")
print("")
print("Test this kernel config again:")
print(f" pmbootstrap kconfig check {last_failed}")
print("")
print("Run this check again (on all kernels you modified):")
print(" pmbootstrap ci kconfig")
print("")
if __name__ == "__main__":
common.add_upstream_git_remote()
pkgnames = common.get_changed_kernels()
print(f"Changed kernels: {pkgnames}")
if len(pkgnames) == 0:
print("No kernels changed in this branch")
exit(0)
# Initialize args (so we can use pmbootstrap's kconfig parsing)
sys.argv = ["pmbootstrap", "kconfig", "check"]
args = pmb.parse.arguments()
pmb.helpers.logging.init(args)
print("Running kconfig check on changed kernels...")
last_failed = check_kconfig(args, pkgnames)
if last_failed:
show_error(last_failed)
exit(1)
-17
View File
@@ -1,17 +0,0 @@
#!/bin/sh -e
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
if ! mount | grep -q /proc/sys/fs/binfmt_misc; then
echo "Mounting binfmt_misc"
mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
fi
if id "build" > /dev/null 2>&1; then
echo "User 'build' exists already"
else
echo "Creating build user"
adduser -D build
chown -R build:build .
echo 'build ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
fi
+1 -1
View File
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
if [ -z "$1" ]; then
echo "usage: $(basename "$0") \$CI_PROJECT_DIR"
echo "usage: $(basename $0) \$CI_PROJECT_DIR"
exit 1
fi
+5 -17
View File
@@ -1,26 +1,15 @@
#!/bin/sh -e
# Copyright 2023 Oliver Smith
# Copyright 2021 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
# Description: lint with various python tests
# Options: native
# Use 'native' because it requires pmbootstrap.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
wget "https://gitlab.com/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
sh ./install_pmbootstrap.sh pytest
exec su "${TESTUSER:-pmos}" -c "sh -e $0"
fi
# Require pytest to be installed on the host system
if [ -z "$(command -v pytest)" ]; then
echo "ERROR: pytest command not found, make sure it is in your PATH."
# Require pmbootstrap
if ! command -v pmbootstrap > /dev/null; then
echo "ERROR: pmbootstrap needs to be installed."
exit 1
fi
# Wrap pmbootstrap to use this repository for --aports
pmaports="$(cd "$(dirname "$0")"/..; pwd -P)"
pmaports="$(cd $(dirname $0)/..; pwd -P)"
_pmbootstrap="$(command -v pmbootstrap)"
pmbootstrap() {
"$_pmbootstrap" --aports="$pmaports" "$@"
@@ -34,7 +23,6 @@ pmbootstrap -q shutdown
# Make sure we have a valid device (pmbootstrap#1128)
device="$(pmbootstrap config device)"
deviceinfo="$pmaports/device/*/device-$device/deviceinfo"
# shellcheck disable=SC2086
if ! [ -e $deviceinfo ]; then
echo "ERROR: Could not find deviceinfo file for selected device '$device'."
echo "Expected path: $deviceinfo"
+17 -16
View File
@@ -1,15 +1,16 @@
#!/bin/sh -e
# Copyright 2023 Oliver Smith
# Copyright 2021 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
# Description: lint all shell scripts
# https://postmarketos.org/pmb-ci
DIR="$(cd "$(dirname "$0")/.." && pwd -P)"
set -e
DIR="$(cd "$(dirname "$0")" && pwd -P)"
cd "$DIR/.."
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add shellcheck
exec su "${TESTUSER:-build}" -c "sh -e $0"
# Find CHANGEMEs in APKBUILDs
if grep -qr '(CHANGEME!)' *; then
echo "ERROR: Please replace '(CHANGEME!)' in the following files:"
grep --color=always -r '(CHANGEME!)' *
exit 1
fi
# Shell: shellcheck
@@ -17,18 +18,19 @@ sh_files="
./main/mdss-fb-init-hack/mdss-fb-init-hack.sh
./main/osk-sdl/unlock.sh
./main/postmarketos-base/rootfs-usr-lib-firmwareload.sh
./main/postmarketos-base-ui/rootfs-etc-NetworkManager-dispatcher.d-99-dns-filter.sh
./main/postmarketos-base-ui/rootfs-etc-NetworkManager-dispatcher.d-85-tethering
./main/postmarketos-installkernel/installkernel-pmos
./main/postmarketos-initramfs/init.sh
./main/postmarketos-initramfs/init_functions.sh
./main/postmarketos-mkinitfs/init.sh
./main/postmarketos-mkinitfs/init_functions.sh
./main/postmarketos-mkinitfs-hook-debug-shell/20-debug-shell.sh
./main/postmarketos-mkinitfs-hook-netboot/netboot.sh
./main/postmarketos-update-kernel/update-kernel.sh
./main/swclock-offset/swclock-offset-boot.sh
./main/swclock-offset/swclock-offset-shutdown.sh
./main/ttyescape/*.sh
./main/ttyescape/*.post-install
./main/unl0kr/unlock.sh
./main/msm-firmware-loader/*.sh
./main/msm-firmware-loader/*.post-install
./device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.sh
$(find . -path './main/postmarketos-ui-*/*.sh')
$(find . -path './main/postmarketos-ui-*/*.pre-install')
@@ -42,11 +44,10 @@ sh_files="
$(find . -path './main/devicepkg-dev/*.sh')
$(find . -path './main/postmarketos-mvcfg/*.sh')
$(find . -path './.ci/**.sh')
$(find . -path '.ci/*.sh')
"
for file in $sh_files; do
echo "Test with shellcheck: $file"
cd "$DIR/$(dirname "$file")"
cd "$DIR/../$(dirname "$file")"
shellcheck -e SC1008 -x "$(basename "$file")"
done
@@ -15,10 +15,8 @@ def path_pmbootstrap():
code from there.
returns: pmbootstrap installation folder
"""
# This variable is set by pmbootstrap 1.52 and later
# If it's undefined, try to find 'pmbootstrap' in path
bin = os.environ.get("PMBOOTSTRAP_CMD") or shutil.which("pmbootstrap")
# Find 'pmbootstrap' executable
bin = shutil.which("pmbootstrap")
if not bin:
print("ERROR: 'pmbootstrap' not found in $PATH")
sys.exit(1)
+9 -11
View File
@@ -16,18 +16,20 @@ def device_dependency_check(apkbuild, path):
""" Raise an error if a device package has a dependency that is not allowed
(e.g. because it should be in a subpackage instead). """
# asus-me176c: without this, the device will simply run the broken ACPI
# DSDT table, so we might as well update it. See pmaports!699.
firmware_ok = {"device-asus-me176c": ["firmware-asus-me176c-acpi"]}
pkgname = apkbuild["pkgname"]
for depend in apkbuild["depends"]:
if depend == "linux-firmware-none":
continue
if (depend.startswith("firmware-") or
depend.startswith("linux-firmware")):
if pkgname in firmware_ok and depend in firmware_ok[pkgname]:
continue
raise RuntimeError("Firmware package '" + depend + "' found in"
" depends of " + path + ". These go into"
" subpackages now, see"
" <https://postmarketos.org/devicepkg>.")
if depend == "mesa-dri-gallium":
raise RuntimeError(f"{path}: mesa-dri-gallium shouldn't be in"
" depends anymore (see pmaports!3478)")
def test_aports_device(args):
@@ -38,11 +40,7 @@ def test_aports_device(args):
apkbuild = pmb.parse.apkbuild(path)
# Depends: Require "postmarketos-base"
depend_flag = False
for dependency in apkbuild["depends"]:
if "postmarketos-base" == dependency or "postmarketos-base>" in dependency:
depend_flag = True
if not depend_flag:
if "postmarketos-base" not in apkbuild["depends"]:
raise RuntimeError("Missing 'postmarketos-base' in depends of " +
path)
@@ -85,7 +83,7 @@ def test_aports_device_kernel(args):
# Parse kernels from depends
kernels_depends = []
for depend in apkbuild["depends"]:
if not depend.startswith("linux-") or depend.startswith("linux-firmware-"):
if not depend.startswith("linux-"):
continue
kernels_depends.append(depend)
+7 -28
View File
@@ -3,10 +3,9 @@
# SPDX-License-Identifier: GPL-3.0-or-later
import glob
import os
import pytest
import re
import sys
import os
import add_pmbootstrap_to_import_path
import pmb.parse
@@ -17,15 +16,12 @@ def deviceinfo_obsolete(info):
Test for obsolete options used in the deviceinfo file. They must still be
defined in pmbootstrap's config/__init__.py.
"""
obsolete_options = [
"usb_rndis_function",
"weston_pixman_type",
]
obsolete_options = ["weston_pixman_type"]
for option in obsolete_options:
if option in info and info[option]:
raise RuntimeError(f"option {option} is obsolete, please rename"
" or remove it (see reasons for removal of at"
" https://postmarketos.org/deviceinfo)")
if info[option]:
raise RuntimeError("option '" + option + "' is obsolete, please"
" remove it (reasons for removal are at"
" <https://postmarketos.org/deviceinfo>)")
def test_deviceinfo(args):
@@ -35,8 +31,6 @@ def test_deviceinfo(args):
# Iterate over all devices
last_exception = None
count = 0
pattern = re.compile("^deviceinfo_[a-zA-Z0-9_]*=\".*\"$")
for folder in glob.glob(args.aports + "/device/*/device-*"):
device = folder[len(args.aports):].split("-", 1)[1]
@@ -45,26 +39,11 @@ def test_deviceinfo(args):
f.close()
try:
# variable can not be empty
for line in lines:
# Require space after # for comments
if line.startswith("#") and not line.startswith("# "):
raise RuntimeError("Comment style: please change '#' to"
f" '# ': {line}")
# Skip empty lines and comments
if not line or line.startswith("# "):
continue
# Variable can not be empty
if '=""' in line:
raise RuntimeError("Please remove the empty variable: " + line)
# Check line against regex (can't use multiple lines etc.)
if not pattern.match(line) or line.endswith("\\\""):
raise RuntimeError("Line looks invalid, maybe missing"
" quotes/multi-line string/comment next"
f" to line instead of above? {line}")
# Successful deviceinfo parsing / obsolete options
info = pmb.parse.deviceinfo(args, device)
deviceinfo_obsolete(info)
+3 -7
View File
@@ -15,13 +15,14 @@ def test_aports_firmware(args):
"""
excluded = [
"firmware-motorola-ali", # Depends on firmware-qcom-adreno-a530
"firmware-motorola-potter", # Depends on soc-qcom-msm8916-ucm
"firmware-oneplus-msm8998", # Depends on soc-qcom-sdm845-nonfree-firmware
"firmware-xiaomi-sagit", # Depends on soc-qcom-sdm845-nonfree-firmware
"firmware-oneplus-sdm845", # Depends on soc-qcom-sdm845-nonfree-firmware
"firmware-samsung-baffinlite", # Depends on firmware-aosp-broadcom-wlan
"firmware-samsung-crespo", # Depends on firmware-aosp-broadcom-wlan
"firmware-samsung-maguro", # Depends on firmware-aosp-broadcom-wlan
"firmware-shift-sdm845", # Depends on soc-qcom-sdm845-nonfree-firmware
"firmware-xiaomi-beryllium", # Depends on soc-qcom-sdm845-nonfree-firmware
"firmware-xiaomi-ferrari", # Depends on soc-qcom-msm8916
"firmware-xiaomi-willow", # Doesn't build, source link is dead (pma#1212)
]
@@ -43,8 +44,3 @@ def test_aports_firmware(args):
raise RuntimeError(f"{aport_name}: \"!tracedeps\" missing in"
" options= line. The tracedeps option is superfluous"
" for firmware packages.")
if "noarch" in apkbuild["arch"]:
raise RuntimeError(f"{aport_name}: \"arch\" must not be \"noarch\"!"
" Please limit this firmware package to the"
" required architectures only!")
+4 -4
View File
@@ -34,9 +34,9 @@ def test_aports_kernel(args):
" pmbootstrap installs cross-compiler"
" automatically.")
# check some options only for main and community devices
# nftables support in kernels used by main and community devices
for dir in ["main", "device/main", "device/community"]:
if path.startswith(f"{args.aports}/{dir}"):
if "pmb:kconfigcheck-community" not in apkbuild["options"]:
raise RuntimeError(f"{aport_name}: \"pmb:kconfigcheck-community\" missing in"
" options= line, required for all community/main devices.")
assert pmb.parse.kconfig.check(args,
aport_name.replace("linux-", ""),
force_nftables_check=True)
-87
View File
@@ -1,87 +0,0 @@
#!/usr/bin/env python3
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import glob
import logging
import os
import pytest
import sys
import add_pmbootstrap_to_import_path
import pmb.parse
import pmb.parse._apkbuild
def apkbuild_check_provides(path, apkbuild, version, pkgname, subpkgname=None):
"""
Verify that a package or subpackage is using provides correctly.
:param path: to the APKBUILD for the error message
:param apkbuild: either the full return of pmb.parse.apkbuild() or a
subpackage of it (apkbuild["subpackages"][$subpkgname])
:param version: like 1.0.0-r3 so we can check against it
:param pkgname: package name
:param subpkgname: subpackage name, if we are looking at a subpackage
:returns: list of error strings
"""
name = pkgname
if subpkgname:
name = f"{pkgname}:{subpkgname}"
logging.info(f"{name}: checking provides")
ret = []
if not apkbuild["provides"]:
return ret
for provide in apkbuild["provides"]:
# Having provides entries without version is valid if the
# provider_priorty is also set (pma#1766)
if apkbuild["provider_priority"]:
continue
# Otherwise the version =$pkgver-r$pkgrel needs to be set. pmbootstrap
# already replaces the variables, so we check against the inserted
# values here.
if not provide.endswith(f"={version}"):
provide_no_ver = provide.split("=", 1)[0]
error = f"error in {path}:\n"
if subpkgname:
error += f"in subpackage:\n {subpkgname}\n"
else:
error += f"in package:\n {pkgname}\n"
error += f"broken provides entry:\n {provide_no_ver}\n"
error += "\n"
error += "This provides entry needs to be changed to"
error += f" '{provide_no_ver}=$pkgver-r$pkgrel'"
error += " (do not replace the variables, without '').\n"
error += "\n"
error += "If you know what you are doing and didn't add the"
error += " version on purpose, you also need to set a"
error += " provider_priority (pma#1766).\n"
error += "Reference:"
error += " https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#provides"
ret += [error]
return ret
def test_provides(args):
errors = []
for path in glob.iglob(f"{args.aports}/**/APKBUILD", recursive=True):
apkbuild = pmb.parse.apkbuild(path)
pkgname = apkbuild["pkgname"]
version = f"{apkbuild['pkgver']}-r{apkbuild['pkgrel']}"
path_rel = os.path.relpath(path, args.aports)
errors += apkbuild_check_provides(path_rel, apkbuild, version, pkgname)
for subpkg, subpkg_data in apkbuild["subpackages"].items():
if not subpkg_data:
# default packaging function like -doc
continue
errors += apkbuild_check_provides(path_rel, subpkg_data, version,
pkgname, subpkg)
if errors:
for error in errors:
logging.error(error)
raise RuntimeError(f"test_provides failed with {len(errors)} errors")
-152
View File
@@ -1,152 +0,0 @@
#!/usr/bin/env python3
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
# Various checks on source= in the APKBUILDs
import glob
import logging
import os
import pytest
import sys
import add_pmbootstrap_to_import_path
import pmb.parse
import pmb.parse._apkbuild
import pmb.parse.apkindex
import pmb.helpers.repo
def parse_source_from_checksums(args, apkbuild_path):
"""
Read the APKBUILD file and parse source files from the checksums at the
bottom. This has always the same format, even if $source is built with hard
to parse shell code (like in postmarketos-base).
:param apkbuild_path: full path to the APKBUILD
:returns: dict of parsed "source" filenames and checksums, e.g.:
{"first.patch": "b4dc4f3…",
"second.patch": "b4dc4f3…"}
"""
start = 'sha512sums="'
in_block = False
ret = {}
with open(apkbuild_path, encoding="utf-8") as handle:
for line in handle.readlines():
# Find start
if not in_block:
if line.startswith(start):
in_block = True
else:
continue
# sha512sums may have lines without checksums:
# https://gitlab.alpinelinux.org/alpine/abuild/-/merge_requests/73
if " " not in line:
continue
try:
checksum, filename = line.rstrip().split(" ", 2)
except ValueError:
raise ValueError("Failed to parse checksums. Try to delete the"
" checksums and generate them again with"
f" 'pmbootstrap checksum': {apkbuild_path}")
# Cut off 'sha512sums="' if the first checksum is in that line
if checksum.startswith(start):
checksum = checksum[len(start):]
# Find end
if filename.endswith('"'):
filename = filename[:-1]
ret[filename] = checksum
return ret
def test_aports_unreferenced_files(args):
"""
Raise an error if an unreferenced file is found
"""
for apkbuild_path in glob.iglob(args.aports + "/**/APKBUILD", recursive=True):
# pmbootstrap parser has some issues with complicated APKBUILDs, skip those.
if apkbuild_path.startswith(args.aports + "/cross/"):
continue
apkbuild = pmb.parse.apkbuild(apkbuild_path)
sources_chk = parse_source_from_checksums(args, apkbuild_path)
# Collect files from subpackages
subpackage_installs = []
subpackage_triggers = []
if apkbuild["subpackages"]:
for subpackage in apkbuild["subpackages"].values():
if not subpackage:
continue
subpackage_installs += subpackage.get("install", [])
subpackage_triggers += subpackage.get("triggers", [])
# Collect trigger files
trigger_sources = []
for trigger in apkbuild["triggers"] + subpackage_triggers:
trigger_sources.append(trigger.split("=")[0])
dirname = os.path.dirname(apkbuild_path)
for file in glob.iglob(dirname + "/**", recursive=True):
rel_file_path = os.path.relpath(file, dirname)
# Skip APKBUILDs and directories
if rel_file_path == "APKBUILD" or os.path.isdir(file):
continue
if os.path.basename(rel_file_path) not in sources_chk \
and rel_file_path not in apkbuild["install"] \
and rel_file_path not in subpackage_installs \
and rel_file_path not in trigger_sources:
raise RuntimeError(f"{apkbuild_path}: found unreferenced file: {rel_file_path}")
def test_distfiles_conflict(args):
"""
Make sure that each filename mentioned in any source= of any APKBUILD
always has the same checksum. This is important because apk caches
downloaded source files in a flat distfiles directory. So if two APKBUILDs
both download a file with the same filename but different checksum, and the
user builds both after each other, abuild will fail on the second build
with a checksum error.
"""
source_all = {}
for apkbuild_path in glob.iglob(f"{args.aports}/**/APKBUILD", recursive=True):
source = parse_source_from_checksums(args, apkbuild_path)
dir_path = os.path.dirname(apkbuild_path)
apkbuild_rel = os.path.relpath(apkbuild_path, args.aports)
for filename, checksum in source.items():
# Files bundled with the APKBUILD don't get copied to the distfiles
# cache, so not relevant for this check. Use glob.glob here and not
# iglob, because we don't want an iterator.
if glob.glob(f"{dir_path}/**/{filename}", recursive=True):
continue
# First time seeing this file
if filename not in source_all:
source_all[filename] = {"checksum": checksum,
"apkbuild_rel": apkbuild_rel}
continue
# Saw this file already with same checksum
if checksum == source_all[filename]["checksum"]:
continue
# Saw this file already with different checksum
logging.error("")
logging.error(f"ERROR: the source file '{filename}' has different"
" checksums in the following files:")
logging.error(f"- {source_all[filename]['apkbuild_rel']}:")
logging.error(f" {source_all[filename]['checksum']}")
logging.error(f"- {apkbuild_rel}:")
logging.error(f" {checksum}")
logging.error("")
logging.error("Fix this by setting a different target filename in"
" the package you modified:")
logging.error("https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#source")
logging.error("")
raise RuntimeError(f"Conflict with source file '{filename}'")
+1 -3
View File
@@ -15,9 +15,7 @@ def test_aports_ui(args):
"""
Raise an error if package in _pmb_recommends is not found
"""
pmaports_cfg = pmb.config.pmaports.read_config(args)
for arch in pmaports_cfg["supported_arches"].split(","):
for arch in pmb.config.build_device_architectures:
for path in glob.iglob(args.aports + "/main/postmarketos-ui-*/APKBUILD"):
apkbuild = pmb.parse.apkbuild(path)
# Skip if arch isn't enabled
+97
View File
@@ -0,0 +1,97 @@
#!/usr/bin/env python3
# Copyright 2021 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import glob
import pytest
import sys
import os
import add_pmbootstrap_to_import_path
import pmb.parse
import pmb.parse._apkbuild
import pmb.parse.apkindex
import pmb.helpers.repo
def parse_source_from_checksums(args, apkbuild_path):
"""
Read the APKBUILD file and parse source files from the checksums at the
bottom. This has always the same format, even if $source is built with hard
to parse shell code (like in postmarketos-base).
:param apkbuild_path: full path to the APKBUILD
:returns: list of parsed "source" files, e.g.:
["first.patch", "second.patch"]
"""
start = 'sha512sums="'
in_block = False
ret = []
with open(apkbuild_path, encoding="utf-8") as handle:
for line in handle.readlines():
# Find start
if not in_block:
if line.startswith(start):
in_block = True
else:
continue
# sha512sums may have lines without checksums:
# https://gitlab.alpinelinux.org/alpine/abuild/-/merge_requests/73
if " " not in line:
continue
try:
_, filename = line.rstrip().split(" ", 2)
except ValueError:
raise ValueError("Failed to parse checksums. Try to delete the"
" checksums and generate them again with"
f" 'pmbootstrap checksum': {apkbuild_path}")
# Find end
if filename.endswith('"'):
ret += [filename[:-1]]
break
ret += [filename]
return ret
def test_aports_unreferenced_files(args):
"""
Raise an error if an unreferenced file is found
"""
for apkbuild_path in glob.iglob(args.aports + "/**/APKBUILD", recursive=True):
apkbuild = pmb.parse.apkbuild(apkbuild_path)
sources_chk = parse_source_from_checksums(args, apkbuild_path)
# Collect install files from subpackages
subpackage_installs = []
if apkbuild["subpackages"]:
for subpackage in apkbuild["subpackages"].values():
if not subpackage:
continue
try:
subpackage_installs += subpackage["install"]
except KeyError:
continue
# Collect trigger files
trigger_sources = []
if apkbuild["triggers"]:
for trigger in apkbuild["triggers"]:
trigger_sources.append(trigger.split("=")[0])
dirname = os.path.dirname(apkbuild_path)
for file in glob.iglob(dirname + "/**", recursive=True):
rel_file_path = os.path.relpath(file, dirname)
# Skip APKBUILDs and directories
if rel_file_path == "APKBUILD" or os.path.isdir(file):
continue
if os.path.basename(rel_file_path) not in sources_chk \
and rel_file_path not in apkbuild["install"] \
and rel_file_path not in subpackage_installs \
and rel_file_path not in trigger_sources:
raise RuntimeError(f"{apkbuild_path}: found unreferenced file: {rel_file_path}")
-15
View File
@@ -1,15 +0,0 @@
#!/bin/sh -e
# Description: verify devices are documented in the wiki
# Options: native
# Run natively so we don't need to set up a chroot, python3 is the only dep.
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add \
python3
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
set -x
.ci/lib/check_devices_in_wiki.py --booting
-3
View File
@@ -1,3 +0,0 @@
{
"SpacesAftertabs": true
}
+2 -2
View File
@@ -7,8 +7,8 @@
# Top-most EditorConfig file.
root = true
[{**.{md,ini,sh,rules,nft},**/APKBUILD}]
[**/APKBUILD]
indent_style = tab
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
trim_trailing_whitespace = true
-119
View File
@@ -1,119 +0,0 @@
#!/bin/sh
#
# This hook checks that all local sources specified in the staged APKBUILDs
# are staged too or already committed and that checksums are correct.
#
set -eu
# Maximal allowed size (in bytes) of a file.
FILE_SIZE_LIMIT=262144 # 256 kiB
if ! command -v sha512sum >/dev/null; then
# macOS / BSDs (?) don't have sha512sum, but shasum.
alias sha512sum='shasum -a 512'
fi
error() {
printf '\033[0;31mpre-commit:\033[0m %s\n' "$1" >&2 # red
}
# Prints paths of created or modified files being committed.
changed_files() {
git diff-index \
--name-only \
--cached \
--diff-filter=ACMR HEAD \
-- "$@"
}
# Prints file names and checksums (in format <SHA-512>:<filename>) of local
# sources specified in the APKBUILD ($1).
apkbuild_local_sources() {
apkbuild="$1"
set +eu
. "$apkbuild" || {
error "$apkbuild is invalid"
return 1
}
set -eu
status=0
: ${source:=""}
for src in $source; do
# Skip remote sources.
case "$src" in */*) continue;; esac
echo "$sha512sums" | awk -v src="$src" '
{ if ($2 == src) { ok=1; print($2 ":" $1) } }
END { if (ok != 1) exit 1 }' || {
status=1
error "${apkbuild%/*}: file \"$src\" is missing in \$sha512sums (hint: run pmbootstrap checksum)"
}
done
return $status
}
# check if given object is a symlink
is_symlink() {
test "$(git ls-files --stage "$1" | awk '{print $1}')" = "120000"
}
# Checks that all local sources specified in the APKBUILD file ($1) are
# available in git tree and checksums are correct.
check_local_sources() {
local apkbuild="$1"
local startdir="${apkbuild%/*}"
local status=0
local checksum_act checksum_exp content filename line sources
sources=$(apkbuild_local_sources "$apkbuild")
for line in $sources; do
filename=${line%%:*}
checksum_exp=${line#*:}
if ! git cat-file -e ":$startdir/$filename" 2>/dev/null; then
error "$startdir: missing file \"$filename\""
status=1
continue
fi
if is_symlink ":$startdir/$filename"; then
continue
fi
checksum_act=$(git show ":$startdir/$filename" | sha512sum)
if [ "$checksum_act" != "$checksum_exp -" ]; then
local cmd="pmbootstrap checksum $(basename "$startdir")"
error "$startdir: bad checksum for file \"$filename\" (hint: run $cmd)"
status=1
fi
done
return $status
}
# Checks if the file ($1) being committed is not bigger than FILE_SIZE_LIMIT.
check_file_size() {
local path="$1"
local size
size=$(git cat-file -s ":$path")
if [ $size -gt $FILE_SIZE_LIMIT ]; then
local size_kb=$(( size / 1024 ))
error "file \"$path\" is quite big ($(( size / 1024 )) kiB), better put a remote url in source="
return 1
fi
}
for apkbuild in $(changed_files '**/APKBUILD'); do
check_local_sources "$apkbuild"
done
for path in $(changed_files); do
check_file_size "$path"
done
-49
View File
@@ -1,49 +0,0 @@
#!/bin/sh
#
# This hook adds prefix "<repo>/<pkgname>: " to the commit message when
# committing changes of a single package.
#
MSG_FILE="$1"
SOURCE="$2"
longest_common_prefix() {
awk -F/ '
(NR == 1) { split($0, prefix); prefix_len = NF }
(NR > 1) {
for (i = 1; i <= prefix_len; i++) {
if (prefix[i] != $i) {
prefix_len = i - 1; break
}
}
}
(prefix_len == 0) { exit }
END {
res = prefix[1]
for (i = 2; i <= prefix_len; i++) {
res = res FS prefix[i]
}
print(res)
}'
}
prepend_msg() {
local prefix="$1"
printf '%s\n%s\n' "$prefix" "$(cat "$MSG_FILE")" > "$MSG_FILE"
}
# Do nothing if message has been given using -m, template, merge etc.
[ -z "$SOURCE" ] || exit 0
lcp=$(git diff-index --name-only --cached HEAD | longest_common_prefix)
case "$lcp" in
device/*/*) prepend_msg "$(echo "$lcp" | cut -d/ -f3): ";;
# Multiple packages touched for same device category
# More logic could be added to detect if they all belong to same device
device/*) ;;
[^.]*/*) prepend_msg "$(echo "$lcp" | cut -d/ -f1-2): ";;
esac
exit 0
+1
View File
@@ -20,6 +20,7 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
+40 -44
View File
@@ -3,7 +3,7 @@
# global settings
image: alpine:latest
after_script:
- .ci/lib/move_logs.sh $CI_PROJECT_DIR
- .ci/move_logs.sh $CI_PROJECT_DIR
stages:
- lint
- build
@@ -31,12 +31,13 @@ wiki:
- merge_requests
changes:
- device/*/device-*/*
before_script:
- apk -q add python3
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/wiki.sh
- .ci/check_devices_in_wiki.py --booting
# testcases linting
flake8:
testcases-linting:
stage: lint
<<: *only-default
only:
@@ -48,35 +49,28 @@ flake8:
before_script:
- apk -q add py-flake8
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/flake8.sh
- flake8 --ignore E501,F401,E722,W504,W605
# shellcheck and various grep checks
shellcheck-grep:
# shellcheck
shellcheck:
stage: lint
<<: *only-default
image: alpine:edge
before_script:
- apk -q add shellcheck
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/shellcheck.sh
- .ci/grep.sh
editor-config:
stage: lint
<<: *only-default
image: alpine:edge
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/ec.sh
# aports checks (generic)
pytest-commits:
aports-static:
stage: lint
<<: *only-default
before_script:
- wget "https://gitlab.com/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
- sh ./install_pmbootstrap.sh pytest
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/pytest.sh
- .ci/commits.sh
- su pmos -c ".ci/run_testcases.sh"
- su pmos -c ".ci/check_changed_aports_versions.py"
artifacts:
when: on_failure
paths:
@@ -85,12 +79,26 @@ pytest-commits:
- pmbootstrap.cfg
expire_in: 1 week
distfile-check:
stage: lint
<<: *only-default
before_script:
- apk -q add make findutils
- wget "https://gitlab.com/postmarketOS/ci-common/-/archive/master/ci-common-master.tar.bz2"
- tar -xf ci-common-master.tar.bz2
- mv ci-common-master/distfile-check/*.sh ci-common-master/distfile-check/Makefile .
- rm -r ci-common-master ci-common-master.tar.bz2
script:
- make -j999
# APKBUILD linting
aport-lint:
stage: lint
before_script:
- wget "https://gitlab.com/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
- sh ./install_pmbootstrap.sh
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/apkbuild-lint.sh
- su pmos -c ".ci/apkbuild-linting.py"
only:
- merge_requests
allow_failure: true
@@ -105,9 +113,11 @@ kernel-kconfig:
changes:
- device/*/linux-*/config-*
- main/linux-*/config-*
before_script:
- wget "https://gitlab.com/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
- sh ./install_pmbootstrap.sh pytest
script:
- .ci/lib/gitlab_prepare_ci.sh
- .ci/kconfig.sh
- su pmos -c "pmbootstrap kconfig check"
# MR settings
# (Checks for "Allow commits from members who can merge to the target branch")
@@ -126,41 +136,27 @@ mr-settings:
stage: build
<<: *only-default
before_script:
- .ci/lib/gitlab_prepare_ci.sh
after_script:
- wget "https://gitlab.com/postmarketOS/ci-common/-/raw/master/install_pmbootstrap.sh"
- sh ./install_pmbootstrap.sh
script:
- .ci/build.sh
- cp -r /home/pmos/.local/var/pmbootstrap/packages/ packages/ || true
artifacts:
expire_in: 1 week
paths:
- packages/
timeout: 10 h
build-x86_64:
extends: .build
script:
- .ci/build-x86_64.sh
build-x86:
extends: .build
script:
- .ci/build-x86.sh
build-aarch64:
extends: .build
script:
- .ci/build-aarch64.sh
build-armv7:
extends: .build
script:
- .ci/build-armv7.sh
build-armhf:
extends: .build
script:
- .ci/build-armhf.sh
build-riscv64:
extends: .build
script:
- .ci/build-riscv64.sh
-47
View File
@@ -1,47 +0,0 @@
<!--
Thank you for using postmarketOS! In order to speed up process of resolving your issue,
we would like you to fill in the following :
-->
### Describe your issue
#### What's the expected behaviour?
#### What's the current behaviour?
#### How to reproduce your issue?
### What device are you using?
<!--
Leave name of your device in vendor-codename format.
If unsure, check name in the device package or leave full name of device
PinePhone: which revision exactly? See https://wiki.pine64.org/index.php/PinePhone#Hardware_revisions
-->
### On what postmarketOS version did you encounter the issue?
<!--
Replace space inside `[ ]` with `x` to fill the checkbox
-->
* [ ] edge (`master` branch)
* [ ] `v23.06`
* [ ] `v22.12`
* [ ] I confirm that the issue still is present after running `sudo apk upgrade -a`
### On what environment did you encounter the issue?
#### Environments
* [ ] Phosh
* [ ] Plasma Mobile
* [ ] Sxmo (Wayland/Sway) **Please post the output of `sxmo_version.sh`**
* [ ] Other: **Please fill out**
### How did you get postmarketOS image?
* [ ] from https://images.postmarketos.org
* [ ] I built it using pmbootstrap
* [ ] It was preinstalled on my device
### What's the build date of the image? (in yyyy-mm-dd format)
<!--
Notes:
can be left empty if unsure
If you downloaded image from images.postmarketos.org, date will be in yyyymmdd format
-->
### Additional information
<!-- logs, etc. -- make use <details> for long listings -->
+6 -1
View File
@@ -1,7 +1,12 @@
{
"subject_format": {
"pass": [
"^(([a-z]+\\/[a-z\\-0-9*{}]+),?)+: [A-Za-z\\/\\-0-9*{}\\(\\)\\.,_&:=' ]+( \\(MR \\d+\\)|)$",
"^[a-z]+/[a-z-0-9*{}]+: new aport(s|)( \\(MR \\d+\\)|)$",
"^[a-z]+/[a-z-0-9*{}]+: pkgrel bump( \\(MR \\d+\\)|)$",
"^[a-z-0-9*{}]+: new device \\([^\\)]+\\)( \\(MR \\d+\\)|)",
"^[a-z]+/[a-z-0-9*{}]+: upgrade to [0-9\\.a-z\\-_]+( \\(MR \\d+\\)|)$",
"^[a-z]+/[a-z-0-9*{}]+: remove( \\(MR \\d+\\)|)$",
"^[a-z]+/[a-z-0-9*{}]+: remove, upstreamed( \\(MR \\d+\\)|)$",
"^CI: [a-z-0-9*{}\\(\\)\\.,_ ][A-Za-z\\/\\-0-9*{}\\(\\)\\.,_ ]+( \\(MR \\d+\\)|)$",
"^mrhlpr.json: [a-z-0-9*{}\\(\\)\\.,_ ][A-Za-z\\/\\-0-9*{}\\(\\)\\.,_ ]+( \\(MR \\d+\\)|)$",
"^pmaports.cfg: [a-z-0-9*{}\\(\\)\\.,_ ][A-Za-z\\/\\-0-9*{}\\(\\)\\.,_ ]+( \\(MR \\d+\\)|)$"
+7 -85
View File
@@ -1,88 +1,10 @@
# https://docs.gitlab.com/ee/user/project/code_owners.html
device/*/*-htc-golfu/ @Newbyte
device/*/*-pine64-pinephone/ @craftyguy @milesalan @bshah @proycon @anjandev @StacyHarper
device/*/*-htc-m8qlul/ @Newbyte
device/*/*-purism-librem5/ @craftyguy @bshah
device/*/device-lg-judyln/ @Newbyte
device/*/device-samsung-m0/ @Newbyte
device/*/linux-postmarketos-exynos4/ @Newbyte
device/*/linux-postmarketos-msm8939/ @Newbyte
device/*/linux-postmarketos-stericsson/ @Newbyte
device/*/*-qcom-sdm845/ @sdm845-mainline
device/*/*-xiaomi-berrylium/ @joelselvaraj
device/*/device-oneplus-enchilada/ @calebccff
device/*/device-oneplus-fajita/ @calebccff
device/*/firmware-oneplus-sdm845/ @calebccff
device/*/device-shift-axolotl/ @amartinz @calebccff @dylanvanassche
device/*/*-lenovo-a6010/ @jenneron
device/*/*-lenovo-a6000/ @jenneron
device/*/device-microsoft-surface-rt/ @jenneron
device/*/device-google-fennel/ @jenneron
device/*/device-google-veyron-minnie/ @jenneron
device/*/device-google-burnet/ @jenneron
device/*/device-google-elm/ @jenneron
device/*/device-google-nyan-big/ @jenneron
device/*/device-google-peach-pi/ @jenneron
device/*/device-google-veyron-speedy/ @jenneron
device/*/linux-google-veyron/ @jenneron
device/*/u-boot-peach-pi/ @jenneron
device/*/device-google-cozmo/ @jenneron
device/*/u-boot-veyron-speedy/ @jenneron
device/*/device-google-juniper/ @jenneron @binarycraft
device/*/u-boot-peach-pit/ @jenneron
device/*/device-google-damu/ @jenneron
device/*/u-boot-nyan-4gb/ @jenneron
device/*/device-google-kenzo/ @jenneron
device/*/device-google-kodama/ @jenneron
device/*/u-boot-snow/ @jenneron
device/*/device-google-kevin/ @jenneron
device/*/linux-postmarketos-exynos5/ @jenneron @Grimler
device/*/device-google-krane/ @jenneron
device/*/soc-mediatek-mt8183/ @jenneron
device/*/u-boot-veyron-minnie/ @jenneron
device/*/device-google-fennel14/ @jenneron
device/*/linux-google-nyan/ @jenneron
device/*/device-google-willow/ @jenneron
device/*/linux-postmarketos-mediatek-mt8173/ @jenneron
device/*/linux-postmarketos-mediatek-mt8183/ @jenneron @binarycraft
device/*/device-google-nyan-blaze/ @jenneron
device/*/firmware-powervr-gx6250/ @jenneron
device/*/device-google-hana/ @jenneron
device/*/device-google-snow/ @jenneron
device/*/device-google-kappa/ @jenneron
device/*/u-boot-nyan-2gb/ @jenneron
device/*/device-google-veyron-jerry/ @jenneron
device/*/device-google-kakadu/ @jenneron
device/*/firmware-google-veyron-brcm/ @jenneron
device/*/device-google-peach-pit/ @jenneron
device/*/device-lg-judyp/ @jenneron
device/*/device-asus-tf201/ @clamor95
device/*/device-asus-tf300t/ @clamor95
device/*/device-asus-tf300tg/ @clamor95
device/*/device-asus-tf700t/ @clamor95
device/*/device-lg-p895/ @clamor95
device/*/firmware-asus-transformer/ @clamor95 @jenneron
device/*/firmware-lg-x3/ @clamor95
device/*/linux-postmarketos-grate/ @clamor95 @jenneron
device/*/device-samsung-chagallwifi @Grimler
device/*/device-odroid-xu4 @Grimler
device/*/device-samsung-klimtlte @Grimler
device/*/linux-samsung-klimtlte @Grimler
device/*/firmware-odroid-xu4 @Grimler
device/*/linux-samsung-chagallwifi @Grimler
device/*/device-huawei-plank @gtrxAC
device/*/linux-huawei-plank @gtrxAC
device/*/*-pine64-pinephone/ @craftyguy @milesalan @bshah @proycon @anjandev @StacyHarper
device/*/*-purism-librem5/ @craftyguy @bshah
main/osk-sdl/ @craftyguy
main/mesa-pvr-dri-classic/ @xc-racer99
main/postmarketos-ui-plasma-mobile/ @bshah
temp/u-boot-librem5/ @craftyguy @bshah
main/postmarketos-update-depthcharge-kernel/ @jenneron
main/osk-sdl/ @craftyguy
main/postmarketos-ui-plasma-mobile/ @bshah
main/ttyescape @calebccff
temp/u-boot-librem5/ @craftyguy @bshah
temp/alsa-ucm-conf-google-kukui/ @jenneron @binarycraft
temp/alsa-ucm-conf-google-gru/ @jenneron
device/*/*-videostrong-kii-pro/ @vitali64yt
device/*/*-amlogic-s905* @vitali64yt
device/*/linux-postmarketos-amlogic/ @vitali64yt @exkc
# vim: ts=8 sw=4 et
# vim: ts=4 sw=4 et
-89
View File
@@ -1,89 +0,0 @@
# Policy for commits in pmaports
This document defines policy for organising and titling commits for
inclusion in pmaports.
## Definitions
### Device-specific package
A device-specific package is used to apply configuration and
functionality specifically for device support in postmarketOS.
This is in contrast to other packages
(e.g. main/postmarketos-ui-phosh) in postmarketOS that are used
for configuring the distribution without consideration of the
target device.
## General policy
We follow Alpine's aports commit style with some minor exceptions
and additions. Alpine's commit style can be found here:
https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/COMMITSTYLE.md
## Exceptions
### Changes to packages inside of the device directory
While Alpine has the policy of always prefixing package names with
the name of the repository they are in, in the case of pmaports
this can lead to excessively long commit titles due to the nested
subfolders of the device directory. As such, commits changing
packages inside of the device directory should omit the directory
prefix, for example:
device-pine64-pinephone: description of change
Or:
soc-qcom-msm8996: description of change
If the commit only makes device-specific changes, the
commit title can opt to use the following format:
manufacturer-codename: description of change
### Moving devices between categories
As we do not include directory prefixes in device-related commits,
Alpine's commit style for moving packages does not apply. Instead,
we do the following:
manufacturer-codename: move from category to category
For example:
samsung-m0: move from testing to community
## Additions
### Forking packages from Alpine
Run `pmbootstrap aportgen --fork-alpine package` and modify it.
#### Template
- temp/package-name: fork from Alpine
Example: temp/pulseaudio: fork from Alpine
#### Rules
One commit per forked package.
### Adding new devices
Adding a new device package and optionally also a device-specific
Linux and firmware package.
#### Template
- manufacturer-codename: new device
Example: htc-m8qlul: new device
#### Rules
If the device has the option of making use of a device-specific
kernel and/or firmware package, those packages should be included
in the same commit that adds the device package. One device per
commit.
+1 -2
View File
@@ -5,5 +5,4 @@ Helpful resources:
* [APKBUILD reference](https://wiki.alpinelinux.org/wiki/APKBUILD_Reference)
* [Alpine Linux aports](https://gitlab.alpinelinux.org/alpine/aports/)
* [Alpine Linux package search](https://pkgs.alpinelinux.org/packages)
* [postmarketOS package search](https://pkgs.postmarketos.org/packages)
* [postmarketOS commit style](./COMMITSTYLE.md)
* [postmarketOS package search](https://pkgs.postmarketos.org/packages)
+1 -19
View File
@@ -8,26 +8,8 @@ branch_pmaports=master
branch_aports=master
mirrordir_alpine=edge
[v23.06]
description=Upcoming stable release (DO NOT USE)
branch_pmaports=v23.06
branch_aports=3.18-stable
mirrordir_alpine=v3.18
[v22.12]
description=Latest release / Recommended for best stability
branch_pmaports=v22.12
branch_aports=3.17-stable
mirrordir_alpine=v3.17
[v22.06]
description=Old release (unsupported)
branch_pmaports=v22.06
branch_aports=3.16-stable
mirrordir_alpine=v3.16
[v21.12]
description=Old release (unsupported)
description=Latest release / Recommended for best stability
branch_pmaports=v21.12
branch_aports=3.15-stable
mirrordir_alpine=v3.15
+44 -104
View File
@@ -2,35 +2,27 @@
# Generator: pmbootstrap aportgen binutils-aarch64
# Based on: main/binutils
CTARGET_ARCH=aarch64
CTARGET="$(arch_to_hostspec $CTARGET_ARCH)"
pkgname=binutils-aarch64
pkgver=2.40
pkgrel=11
pkgver=2.37
pkgrel=4
pkgdesc="Tools necessary to build programs for aarch64 targets"
url="https://www.gnu.org/software/binutils/"
makedepends_build="bison flex texinfo"
makedepends_host="zlib-dev jansson-dev zstd-dev"
makedepends="$makedepends_build $makedepends_host"
makedepends="gettext libtool autoconf automake bison texinfo"
arch="x86_64"
license="GPL-2.0-or-later AND LGPL-2.1-or-later AND BSD-3-Clause"
subpackages="binutils-dev binutils-doc"
license="GPL-2.0 GPL-3.0-or-later LGPL-2.0 BSD"
source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
CVE-2023-1972.patch
binutils-ld-fix-static-linking.patch
riscv64-textrels.patch
gold-mips.patch
ld-bfd-mips.patch
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
binutils-mips-disable-assert.patch
bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
defang-no-split.patch
"
builddir="$srcdir/binutils-$pkgver"
if [ -z "$BOOTSTRAP" ]; then
makedepends_host="$makedepends_host jansson-dev zstd-dev"
fi
if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then
subpackages="$subpackages binutils-gold"
subpackages=""
fi
if [ "$CHOST" != "$CTARGET" ]; then
@@ -40,14 +32,6 @@ if [ "$CHOST" != "$CTARGET" ]; then
fi
# secfixes:
# 2.40-r10:
# - CVE-2023-1972
# 2.40-r0:
# - CVE-2023-1579
# 2.39-r2:
# - CVE-2022-38533
# 2.39-r0:
# - CVE-2022-38126
# 2.35.2-r1:
# - CVE-2021-3487
# 2.32-r0:
@@ -58,95 +42,51 @@ fi
# 2.28-r1:
# - CVE-2017-7614
prepare() {
default_prepare
# Remove existing empty man pages to force them to be regenerated.
# Workaround for https://gitlab.alpinelinux.org/alpine/aports/-/issues/13034
find "$builddir" -name '[a-z]*\.[0-9]*' -empty -delete
}
build() {
local _sysroot=/
local _cross_configure="--enable-install-libiberty --enable-shared"
local _arch_configure=""
local _gold_configure="--disable-gold"
local _plugin_configure="--enable-plugins"
if [ "$CHOST" != "$CTARGET" ]; then
_sysroot="$CBUILDROOT"
_cross_configure="--disable-install-libiberty"
_plugin_configure="--disable-plugins"
fi
if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then
_gold_configure="--enable-gold"
fi
if [ "$CTARGET_ARCH" = "x86_64" ]; then
_arch_configure="--enable-targets=x86_64-pep"
fi
if [ "$CTARGET_ARCH" = "riscv64" ]; then
_gold_configure="--disable-gold"
fi
CFLAGS="$CFLAGS -O2" \
CXXFLAGS="$CXXFLAGS -O2" \
./configure \
--build=$CBUILD \
--host=$CHOST \
--target=$CTARGET \
--with-build-sysroot="$CBUILDROOT" \
--with-sysroot=$_sysroot \
_target="$(arch_to_hostspec aarch64)"
"$builddir"/configure \
--build="$CBUILD" \
--target=$_target \
--with-lib-path=/usr/lib \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc \
$_arch_configure \
$_cross_configure \
$_gold_configure \
$_plugin_configure \
--disable-gprofng \
--disable-multilib \
--disable-nls \
--disable-werror \
--enable-64-bit-bfd \
--enable-colored-disassembly \
--enable-default-execstack=no \
--enable-default-hash-style=gnu \
--enable-deterministic-archives \
--with-sysroot=/usr/$_target \
--enable-ld=default \
--enable-new-dtags \
--enable-relro \
--enable-threads \
--with-bugurl="https://postmarketos.org/issues" \
--with-mmap \
--with-pic \
--with-system-zlib
--enable-gold=yes \
--enable-plugins \
--enable-deterministic-archives \
--disable-multilib \
--disable-werror \
--disable-nls
make
}
package() {
make install DESTDIR="$pkgdir"
if [ -d "$pkgdir"/usr/lib64 ]; then
mv "$pkgdir"/usr/lib64/* "$pkgdir"/usr/lib/
rmdir "$pkgdir"/usr/lib64
fi
if [ "$CHOST" != "$CTARGET" ]; then
# creating cross tools: remove any files that would conflict
# with the native tools, or other cross tools
rm -r "${pkgdir:?}"/usr/share
rm -f "$pkgdir"/usr/lib/libiberty.a
rm -r "${pkgdir:?}"/usr/lib/bfd-plugins
fi
# remove man, info folders
rm -rf "$pkgdir"/usr/share
# remove files that conflict with non-cross binutils
rm -rf "$pkgdir"/usr/lib/bfd-plugins
}
gold() {
pkgdesc="GNU binutils - gold linker"
if [ -e "$pkgdir"/usr/bin/ld.gold ]; then
amove usr/bin/ld.gold
fi
amove usr/$CTARGET/bin/ld.gold
}
sha512sums="
a37e042523bc46494d99d5637c3f3d8f9956d9477b748b3b1f6d7dfbb8d968ed52c932e88a4e946c6f77b8f48f1e1b360ca54c3d298f17193f3b4963472f6925 binutils-2.40.tar.xz
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
b434e126c4c3f70c02b0a5597a0d75a4ea99b1498552c2d0676005ac0ae171c56cf07a6f6e2faa1381f1f4d4a37043a07d177dd4912f09b61109f103853594b2 CVE-2023-1972.patch
5c11aeef6935860a6819ed3a3c93371f052e52b4bdc5033da36037c1544d013b7f12cb8d561ec954fe7469a68f1b66f1a3cd53d5a3af7293635a90d69edd15e7 binutils-2.37.tar.xz
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch
d138691d953c6f49111601df1731db157d2ecedf1593e37ababb5c12ff10572b5f7982288c81579f4a99097780dbb18d3b457f74daab0f935f59423e69cec56f riscv64-textrels.patch
f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch
314d2ef9071c89940aa6c8118e8a1e2f191a5d0a4bf596da1ad9cc84f884d8bc7dea8bd7b9fc3f8f1bddd3fd41c6eb017e1e804044b3bf084df1ed9e6e095e2d ld-bfd-mips.patch
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
609cd90d8b334eb309f586b17b9d335a08d3dbb6def7c3eb5c010028fcb681674031e5b9d853aa7a39a50304356a86afc184b85562b3f228f8197f4d29395c8f binutils-mips-disable-assert.patch
10a0074583d2cc4598710c7e434ba7088da074b105f4f5e951fc61af7150ad62adf60a7c98f6fd13b1771f169e45a5a1ef618240c6893d3f0f3d93fd768a03c6 bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
4652f092c9376f0cb7fd6c72cb37ff7c15c1c6e3408fac79329b7f41a7925c98eb35989a9a040682130988a36401901d6d95afa44f0ce50caa85ee478db6bf03 defang-no-split.patch
"
@@ -1,37 +0,0 @@
Patch-Source: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57;hp=f2f9bde5cde7ff34ed0a4c4682a211d402aa1086
https://sourceware.org/bugzilla/show_bug.cgi?id=30285
--
From: Nick Clifton <nickc@redhat.com>
Date: Thu, 30 Mar 2023 09:10:09 +0000 (+0100)
Subject: Fix an illegal memory access when an accessing a zer0-lengthverdef table.
X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57;hp=f2f9bde5cde7ff34ed0a4c4682a211d402aa1086
Fix an illegal memory access when an accessing a zer0-lengthverdef table.
PR 30285
* elf.c (_bfd_elf_slurp_version_tables): Fail if no version definitions are allocated.
---
diff --git a/bfd/elf.c b/bfd/elf.c
index 027d0143735..185028cbd97 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9030,6 +9030,9 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
bfd_set_error (bfd_error_file_too_big);
goto error_return_verdef;
}
+
+ if (amt == 0)
+ goto error_return_verdef;
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verdef == NULL)
goto error_return_verdef;
@@ -9133,6 +9136,8 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
bfd_set_error (bfd_error_file_too_big);
goto error_return;
}
+ if (amt == 0)
+ goto error_return;
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verdef == NULL)
goto error_return;
@@ -0,0 +1,234 @@
Upstream: yes
URL: https://sourceware.org/bugzilla/show_bug.cgi?id=28138
From 1c611b40e6bfc8029bff7696814330b5bc0ee5c0 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 26 Jul 2021 05:59:55 -0700
Subject: [PATCH] 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)
---
bfd/plugin.c | 8 +++++++
ld/testsuite/ld-plugin/lto.exp | 34 ++++++++++++++++++++++++++++++
ld/testsuite/ld-plugin/pr28138-1.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-2.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-3.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-4.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-5.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-6.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-7.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138.c | 20 ++++++++++++++++++
10 files changed, 104 insertions(+)
create mode 100644 ld/testsuite/ld-plugin/pr28138-1.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-2.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-3.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-4.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-5.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-6.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-7.c
create mode 100644 ld/testsuite/ld-plugin/pr28138.c
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 6cfa2b66470..3bab8febe88 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -291,6 +291,14 @@ bfd_plugin_close_file_descriptor (bfd *abfd, int fd)
&& !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. */
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index def69e43ab3..999d911ce6a 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -687,6 +687,40 @@ if { [is_elf_format] && [check_lto_shared_available] } {
}
}
+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"]
diff --git a/ld/testsuite/ld-plugin/pr28138-1.c b/ld/testsuite/ld-plugin/pr28138-1.c
new file mode 100644
index 00000000000..51d119e1642
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-1.c
@@ -0,0 +1,6 @@
+extern int a0(void);
+int
+a1(void)
+{
+ return 1 + a0();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-2.c b/ld/testsuite/ld-plugin/pr28138-2.c
new file mode 100644
index 00000000000..1120cd797e9
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-2.c
@@ -0,0 +1,6 @@
+extern int a1(void);
+int
+a2(void)
+{
+ return 1 + a1();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-3.c b/ld/testsuite/ld-plugin/pr28138-3.c
new file mode 100644
index 00000000000..ec464947ee6
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-3.c
@@ -0,0 +1,6 @@
+extern int a2(void);
+int
+a3(void)
+{
+ return 1 + a2();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-4.c b/ld/testsuite/ld-plugin/pr28138-4.c
new file mode 100644
index 00000000000..475701b2c5c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-4.c
@@ -0,0 +1,6 @@
+extern int a3(void);
+int
+a4(void)
+{
+ return 1 + a3();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-5.c b/ld/testsuite/ld-plugin/pr28138-5.c
new file mode 100644
index 00000000000..e24f86c363e
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-5.c
@@ -0,0 +1,6 @@
+extern int a4(void);
+int
+a5(void)
+{
+ return 1 + a4();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-6.c b/ld/testsuite/ld-plugin/pr28138-6.c
new file mode 100644
index 00000000000..b5b938bdb21
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-6.c
@@ -0,0 +1,6 @@
+extern int a5(void);
+int
+a6(void)
+{
+ return 1 + a5();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-7.c b/ld/testsuite/ld-plugin/pr28138-7.c
new file mode 100644
index 00000000000..4ef75bf0f0c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-7.c
@@ -0,0 +1,6 @@
+extern int a6(void);
+int
+a7(void)
+{
+ return 1 + a6();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138.c b/ld/testsuite/ld-plugin/pr28138.c
new file mode 100644
index 00000000000..68252c9f382
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+extern int a7(void);
+
+int
+a0(void)
+{
+ return 0;
+}
+
+int
+main()
+{
+ if (a7() == 7)
+ {
+ printf ("PASS\n");
+ return 0;
+ }
+ return 1;
+}
--
2.27.0
@@ -0,0 +1,14 @@
diff -urN binutils-2.35.2.orig/bfd/elfxx-mips.c binutils-2.35.2/bfd/elfxx-mips.c
--- binutils-2.35.2.orig/bfd/elfxx-mips.c 2021-01-30 01:38:03.000000000 -0700
+++ binutils-2.35.2/bfd/elfxx-mips.c 2021-05-13 17:35:34.706913601 -0600
@@ -6744,8 +6744,10 @@
in the relocation. */
if (h != NULL && ! SYMBOL_REFERENCES_LOCAL (info, &h->root))
{
+#if 0
BFD_ASSERT (htab->root.target_os == is_vxworks
|| h->global_got_area != GGA_NONE);
+#endif
indx = h->root.dynindx;
if (SGI_COMPAT (output_bfd))
defined_p = h->root.def_regular;
@@ -0,0 +1,38 @@
From 2dad02b6d46eef438cbd14d8511487b056628a38 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <siarheit@google.com>
Date: Mon, 26 Jul 2021 22:51:18 +0100
Subject: [PATCH 1/1] texi2pod.pl: add no-op --no-split option support
[PR28144]
Change 2faf902da ("generate single html manual page by default")
added use of --no-split option to makeinfo. binutils reuses
makeinfo options for texi2pod.pl wrapper. Unsupported option
led to silent manpage truncation.
The change adds no-op option support.
etc/
PR 28144
* texi2pod.pl: Handle no-op --no-split option.
(cherry picked from commit 96a7037cd8573cf065aa6b12baca68696f96d9ca)
---
etc/texi2pod.pl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/etc/texi2pod.pl b/etc/texi2pod.pl
index 11f70d156be..dcf2b437640 100644
--- a/etc/texi2pod.pl
+++ b/etc/texi2pod.pl
@@ -59,6 +59,8 @@ while ($_ = shift) {
$flag = shift;
}
push (@ipath, $flag);
+ } elsif (/^--no-split$/) {
+ # ignore option for makeinfo compatibility
} elsif (/^-/) {
usage();
} else {
--
2.27.0
+39
View File
@@ -0,0 +1,39 @@
# DP: Fix gold on mips64 targets.
gold/
2016-08-09 Aurelien Jarno <aurelien@aurel32.net>
* configure.tgt: Add mips64el*-*-*|mips64le*-*-* and mips64*-*-*.
--- a/gold/configure.tgt
+++ b/gold/configure.tgt
@@ -153,6 +153,13 @@ aarch64*-*)
targ_big_endian=false
targ_extra_big_endian=true
;;
+mips*64*el*-*-*|mips*64*le*-*-*)
+ targ_obj=mips
+ targ_machine=EM_MIPS_RS3_LE
+ targ_size=64
+ targ_big_endian=false
+ targ_extra_big_endian=true
+ ;;
mips*el*-*-*|mips*le*-*-*)
targ_obj=mips
targ_machine=EM_MIPS_RS3_LE
@@ -160,6 +167,13 @@ mips*el*-*-*|mips*le*-*-*)
targ_big_endian=false
targ_extra_big_endian=true
;;
+mips*64*-*-*)
+ targ_obj=mips
+ targ_machine=EM_MIPS
+ targ_size=64
+ targ_big_endian=true
+ targ_extra_big_endian=false
+ ;;
mips*-*-*)
targ_obj=mips
targ_machine=EM_MIPS
+19
View File
@@ -0,0 +1,19 @@
--- ./ld/configure.tgt.orig
+++ ./ld/configure.tgt
@@ -541,12 +541,12 @@
;;
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="elf32ltsmipn32 elf32btsmipn32 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
@@ -1,103 +0,0 @@
Patch-Source: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=225df051d3d4cf714d1791b9035966a6686b3f3d;hp=a70d5ba34cb64bbbb7df4f3055cf5b1967bdf61e#patch1
https://sourceware.org/bugzilla/show_bug.cgi?id=25694
--
From: Nelson Chu <nelson@nelson.ba.rivosinc.com>
Date: Thu, 4 May 2023 09:08:50 +0000 (+0800)
Subject: [PR ld/22263][PR ld/25694] RISC-V: Avoid dynamic TLS relocs in PIE.
X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=225df051d3d4cf714d1791b9035966a6686b3f3d;hp=a70d5ba34cb64bbbb7df4f3055cf5b1967bdf61e
[PR ld/22263][PR ld/25694] RISC-V: Avoid dynamic TLS relocs in PIE.
Lots of targets already fixed the TEXTREL problem for TLS in PIE.
* For PR ld/25694,
In the check_reloc, refer to spare and loongarch, they don't need to reserve
any local dynamic reloc for TLS LE in pie/pde, and similar to other targets.
So it seems like riscv was too conservative to estimate the TLS LE before.
Just break and don't goto static_reloc for TLS LE in pie/pde can fix the
TEXTREL problem.
* For PR ld/22263,
The risc-v code for TLS GD/IE in the relocate_section seems same as MIPS port.
So similar to MIPS, pr22570, commits 9143e72c6d4d and 1cb83cac9a89, it seems
also the right way to do the same thing for risc-v.
On risc-v, fixes
FAIL: Build pr22263-1
RISC-V haven't supported the TLS transitions, so will need the same fix (use
bfd_link_dll) in the future.
bfd/
PR ld/22263
PR ld/25694
* elfnn-riscv.c (riscv_elf_check_relocs): Replace bfd_link_pic with
bfd_link_dll for TLS IE. Don't need to reserve the local dynamic
relocation for TLS LE in pie/pde, and report error in pic just like
before.
(riscv_elf_relocate_section): For TLS GD/IE, use bfd_link_dll rather
than !bfd_link_pic in determining the dynamic symbol index. Avoid
the index of -1.
---
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 75af040cf92..762ea231c0b 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -824,7 +824,7 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
break;
case R_RISCV_TLS_GOT_HI20:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
info->flags |= DF_STATIC_TLS;
if (!riscv_elf_record_got_reference (abfd, info, h, r_symndx)
|| !riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_IE))
@@ -920,11 +920,12 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
goto static_reloc;
case R_RISCV_TPREL_HI20:
+ /* This is not allowed in the pic, but okay in pie. */
if (!bfd_link_executable (info))
return bad_static_reloc (abfd, r_type, h);
if (h != NULL)
riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_LE);
- goto static_reloc;
+ break;
case R_RISCV_HI20:
if (bfd_link_pic (info))
@@ -2880,24 +2881,20 @@ riscv_elf_relocate_section (bfd *output_bfd,
if (htab->elf.srelgot == NULL)
abort ();
- if (h != NULL)
- {
- bool dyn, pic;
- dyn = htab->elf.dynamic_sections_created;
- pic = bfd_link_pic (info);
-
- if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, pic, h)
- && (!pic || !SYMBOL_REFERENCES_LOCAL (info, h)))
- indx = h->dynindx;
- }
+ bool dyn = elf_hash_table (info)->dynamic_sections_created;
+ if (h != NULL
+ && h->dynindx != -1
+ && WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h)
+ && (bfd_link_dll (info) || !SYMBOL_REFERENCES_LOCAL (info, h)))
+ indx = h->dynindx;
/* The GOT entries have not been initialized yet. Do it
now, and emit any relocations. */
- if ((bfd_link_pic (info) || indx != 0)
+ if ((bfd_link_dll (info) || indx != 0)
&& (h == NULL
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak))
- need_relocs = true;
+ need_relocs = true;
if (tls_type & GOT_TLS_GD)
{
+44 -104
View File
@@ -2,35 +2,27 @@
# Generator: pmbootstrap aportgen binutils-armhf
# Based on: main/binutils
CTARGET_ARCH=armhf
CTARGET="$(arch_to_hostspec $CTARGET_ARCH)"
pkgname=binutils-armhf
pkgver=2.40
pkgrel=11
pkgver=2.37
pkgrel=4
pkgdesc="Tools necessary to build programs for armhf targets"
url="https://www.gnu.org/software/binutils/"
makedepends_build="bison flex texinfo"
makedepends_host="zlib-dev jansson-dev zstd-dev"
makedepends="$makedepends_build $makedepends_host"
makedepends="gettext libtool autoconf automake bison texinfo"
arch="x86_64"
license="GPL-2.0-or-later AND LGPL-2.1-or-later AND BSD-3-Clause"
subpackages="binutils-dev binutils-doc"
license="GPL-2.0 GPL-3.0-or-later LGPL-2.0 BSD"
source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
CVE-2023-1972.patch
binutils-ld-fix-static-linking.patch
riscv64-textrels.patch
gold-mips.patch
ld-bfd-mips.patch
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
binutils-mips-disable-assert.patch
bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
defang-no-split.patch
"
builddir="$srcdir/binutils-$pkgver"
if [ -z "$BOOTSTRAP" ]; then
makedepends_host="$makedepends_host jansson-dev zstd-dev"
fi
if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then
subpackages="$subpackages binutils-gold"
subpackages=""
fi
if [ "$CHOST" != "$CTARGET" ]; then
@@ -40,14 +32,6 @@ if [ "$CHOST" != "$CTARGET" ]; then
fi
# secfixes:
# 2.40-r10:
# - CVE-2023-1972
# 2.40-r0:
# - CVE-2023-1579
# 2.39-r2:
# - CVE-2022-38533
# 2.39-r0:
# - CVE-2022-38126
# 2.35.2-r1:
# - CVE-2021-3487
# 2.32-r0:
@@ -58,95 +42,51 @@ fi
# 2.28-r1:
# - CVE-2017-7614
prepare() {
default_prepare
# Remove existing empty man pages to force them to be regenerated.
# Workaround for https://gitlab.alpinelinux.org/alpine/aports/-/issues/13034
find "$builddir" -name '[a-z]*\.[0-9]*' -empty -delete
}
build() {
local _sysroot=/
local _cross_configure="--enable-install-libiberty --enable-shared"
local _arch_configure=""
local _gold_configure="--disable-gold"
local _plugin_configure="--enable-plugins"
if [ "$CHOST" != "$CTARGET" ]; then
_sysroot="$CBUILDROOT"
_cross_configure="--disable-install-libiberty"
_plugin_configure="--disable-plugins"
fi
if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then
_gold_configure="--enable-gold"
fi
if [ "$CTARGET_ARCH" = "x86_64" ]; then
_arch_configure="--enable-targets=x86_64-pep"
fi
if [ "$CTARGET_ARCH" = "riscv64" ]; then
_gold_configure="--disable-gold"
fi
CFLAGS="$CFLAGS -O2" \
CXXFLAGS="$CXXFLAGS -O2" \
./configure \
--build=$CBUILD \
--host=$CHOST \
--target=$CTARGET \
--with-build-sysroot="$CBUILDROOT" \
--with-sysroot=$_sysroot \
_target="$(arch_to_hostspec armhf)"
"$builddir"/configure \
--build="$CBUILD" \
--target=$_target \
--with-lib-path=/usr/lib \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc \
$_arch_configure \
$_cross_configure \
$_gold_configure \
$_plugin_configure \
--disable-gprofng \
--disable-multilib \
--disable-nls \
--disable-werror \
--enable-64-bit-bfd \
--enable-colored-disassembly \
--enable-default-execstack=no \
--enable-default-hash-style=gnu \
--enable-deterministic-archives \
--with-sysroot=/usr/$_target \
--enable-ld=default \
--enable-new-dtags \
--enable-relro \
--enable-threads \
--with-bugurl="https://postmarketos.org/issues" \
--with-mmap \
--with-pic \
--with-system-zlib
--enable-gold=yes \
--enable-plugins \
--enable-deterministic-archives \
--disable-multilib \
--disable-werror \
--disable-nls
make
}
package() {
make install DESTDIR="$pkgdir"
if [ -d "$pkgdir"/usr/lib64 ]; then
mv "$pkgdir"/usr/lib64/* "$pkgdir"/usr/lib/
rmdir "$pkgdir"/usr/lib64
fi
if [ "$CHOST" != "$CTARGET" ]; then
# creating cross tools: remove any files that would conflict
# with the native tools, or other cross tools
rm -r "${pkgdir:?}"/usr/share
rm -f "$pkgdir"/usr/lib/libiberty.a
rm -r "${pkgdir:?}"/usr/lib/bfd-plugins
fi
# remove man, info folders
rm -rf "$pkgdir"/usr/share
# remove files that conflict with non-cross binutils
rm -rf "$pkgdir"/usr/lib/bfd-plugins
}
gold() {
pkgdesc="GNU binutils - gold linker"
if [ -e "$pkgdir"/usr/bin/ld.gold ]; then
amove usr/bin/ld.gold
fi
amove usr/$CTARGET/bin/ld.gold
}
sha512sums="
a37e042523bc46494d99d5637c3f3d8f9956d9477b748b3b1f6d7dfbb8d968ed52c932e88a4e946c6f77b8f48f1e1b360ca54c3d298f17193f3b4963472f6925 binutils-2.40.tar.xz
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
b434e126c4c3f70c02b0a5597a0d75a4ea99b1498552c2d0676005ac0ae171c56cf07a6f6e2faa1381f1f4d4a37043a07d177dd4912f09b61109f103853594b2 CVE-2023-1972.patch
5c11aeef6935860a6819ed3a3c93371f052e52b4bdc5033da36037c1544d013b7f12cb8d561ec954fe7469a68f1b66f1a3cd53d5a3af7293635a90d69edd15e7 binutils-2.37.tar.xz
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch
d138691d953c6f49111601df1731db157d2ecedf1593e37ababb5c12ff10572b5f7982288c81579f4a99097780dbb18d3b457f74daab0f935f59423e69cec56f riscv64-textrels.patch
f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch
314d2ef9071c89940aa6c8118e8a1e2f191a5d0a4bf596da1ad9cc84f884d8bc7dea8bd7b9fc3f8f1bddd3fd41c6eb017e1e804044b3bf084df1ed9e6e095e2d ld-bfd-mips.patch
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
609cd90d8b334eb309f586b17b9d335a08d3dbb6def7c3eb5c010028fcb681674031e5b9d853aa7a39a50304356a86afc184b85562b3f228f8197f4d29395c8f binutils-mips-disable-assert.patch
10a0074583d2cc4598710c7e434ba7088da074b105f4f5e951fc61af7150ad62adf60a7c98f6fd13b1771f169e45a5a1ef618240c6893d3f0f3d93fd768a03c6 bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
4652f092c9376f0cb7fd6c72cb37ff7c15c1c6e3408fac79329b7f41a7925c98eb35989a9a040682130988a36401901d6d95afa44f0ce50caa85ee478db6bf03 defang-no-split.patch
"
-37
View File
@@ -1,37 +0,0 @@
Patch-Source: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57;hp=f2f9bde5cde7ff34ed0a4c4682a211d402aa1086
https://sourceware.org/bugzilla/show_bug.cgi?id=30285
--
From: Nick Clifton <nickc@redhat.com>
Date: Thu, 30 Mar 2023 09:10:09 +0000 (+0100)
Subject: Fix an illegal memory access when an accessing a zer0-lengthverdef table.
X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57;hp=f2f9bde5cde7ff34ed0a4c4682a211d402aa1086
Fix an illegal memory access when an accessing a zer0-lengthverdef table.
PR 30285
* elf.c (_bfd_elf_slurp_version_tables): Fail if no version definitions are allocated.
---
diff --git a/bfd/elf.c b/bfd/elf.c
index 027d0143735..185028cbd97 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9030,6 +9030,9 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
bfd_set_error (bfd_error_file_too_big);
goto error_return_verdef;
}
+
+ if (amt == 0)
+ goto error_return_verdef;
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verdef == NULL)
goto error_return_verdef;
@@ -9133,6 +9136,8 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
bfd_set_error (bfd_error_file_too_big);
goto error_return;
}
+ if (amt == 0)
+ goto error_return;
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verdef == NULL)
goto error_return;
@@ -0,0 +1,234 @@
Upstream: yes
URL: https://sourceware.org/bugzilla/show_bug.cgi?id=28138
From 1c611b40e6bfc8029bff7696814330b5bc0ee5c0 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 26 Jul 2021 05:59:55 -0700
Subject: [PATCH] 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)
---
bfd/plugin.c | 8 +++++++
ld/testsuite/ld-plugin/lto.exp | 34 ++++++++++++++++++++++++++++++
ld/testsuite/ld-plugin/pr28138-1.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-2.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-3.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-4.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-5.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-6.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-7.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138.c | 20 ++++++++++++++++++
10 files changed, 104 insertions(+)
create mode 100644 ld/testsuite/ld-plugin/pr28138-1.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-2.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-3.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-4.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-5.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-6.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-7.c
create mode 100644 ld/testsuite/ld-plugin/pr28138.c
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 6cfa2b66470..3bab8febe88 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -291,6 +291,14 @@ bfd_plugin_close_file_descriptor (bfd *abfd, int fd)
&& !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. */
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index def69e43ab3..999d911ce6a 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -687,6 +687,40 @@ if { [is_elf_format] && [check_lto_shared_available] } {
}
}
+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"]
diff --git a/ld/testsuite/ld-plugin/pr28138-1.c b/ld/testsuite/ld-plugin/pr28138-1.c
new file mode 100644
index 00000000000..51d119e1642
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-1.c
@@ -0,0 +1,6 @@
+extern int a0(void);
+int
+a1(void)
+{
+ return 1 + a0();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-2.c b/ld/testsuite/ld-plugin/pr28138-2.c
new file mode 100644
index 00000000000..1120cd797e9
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-2.c
@@ -0,0 +1,6 @@
+extern int a1(void);
+int
+a2(void)
+{
+ return 1 + a1();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-3.c b/ld/testsuite/ld-plugin/pr28138-3.c
new file mode 100644
index 00000000000..ec464947ee6
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-3.c
@@ -0,0 +1,6 @@
+extern int a2(void);
+int
+a3(void)
+{
+ return 1 + a2();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-4.c b/ld/testsuite/ld-plugin/pr28138-4.c
new file mode 100644
index 00000000000..475701b2c5c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-4.c
@@ -0,0 +1,6 @@
+extern int a3(void);
+int
+a4(void)
+{
+ return 1 + a3();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-5.c b/ld/testsuite/ld-plugin/pr28138-5.c
new file mode 100644
index 00000000000..e24f86c363e
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-5.c
@@ -0,0 +1,6 @@
+extern int a4(void);
+int
+a5(void)
+{
+ return 1 + a4();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-6.c b/ld/testsuite/ld-plugin/pr28138-6.c
new file mode 100644
index 00000000000..b5b938bdb21
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-6.c
@@ -0,0 +1,6 @@
+extern int a5(void);
+int
+a6(void)
+{
+ return 1 + a5();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-7.c b/ld/testsuite/ld-plugin/pr28138-7.c
new file mode 100644
index 00000000000..4ef75bf0f0c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-7.c
@@ -0,0 +1,6 @@
+extern int a6(void);
+int
+a7(void)
+{
+ return 1 + a6();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138.c b/ld/testsuite/ld-plugin/pr28138.c
new file mode 100644
index 00000000000..68252c9f382
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+extern int a7(void);
+
+int
+a0(void)
+{
+ return 0;
+}
+
+int
+main()
+{
+ if (a7() == 7)
+ {
+ printf ("PASS\n");
+ return 0;
+ }
+ return 1;
+}
--
2.27.0
@@ -0,0 +1,14 @@
diff -urN binutils-2.35.2.orig/bfd/elfxx-mips.c binutils-2.35.2/bfd/elfxx-mips.c
--- binutils-2.35.2.orig/bfd/elfxx-mips.c 2021-01-30 01:38:03.000000000 -0700
+++ binutils-2.35.2/bfd/elfxx-mips.c 2021-05-13 17:35:34.706913601 -0600
@@ -6744,8 +6744,10 @@
in the relocation. */
if (h != NULL && ! SYMBOL_REFERENCES_LOCAL (info, &h->root))
{
+#if 0
BFD_ASSERT (htab->root.target_os == is_vxworks
|| h->global_got_area != GGA_NONE);
+#endif
indx = h->root.dynindx;
if (SGI_COMPAT (output_bfd))
defined_p = h->root.def_regular;
@@ -0,0 +1,38 @@
From 2dad02b6d46eef438cbd14d8511487b056628a38 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <siarheit@google.com>
Date: Mon, 26 Jul 2021 22:51:18 +0100
Subject: [PATCH 1/1] texi2pod.pl: add no-op --no-split option support
[PR28144]
Change 2faf902da ("generate single html manual page by default")
added use of --no-split option to makeinfo. binutils reuses
makeinfo options for texi2pod.pl wrapper. Unsupported option
led to silent manpage truncation.
The change adds no-op option support.
etc/
PR 28144
* texi2pod.pl: Handle no-op --no-split option.
(cherry picked from commit 96a7037cd8573cf065aa6b12baca68696f96d9ca)
---
etc/texi2pod.pl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/etc/texi2pod.pl b/etc/texi2pod.pl
index 11f70d156be..dcf2b437640 100644
--- a/etc/texi2pod.pl
+++ b/etc/texi2pod.pl
@@ -59,6 +59,8 @@ while ($_ = shift) {
$flag = shift;
}
push (@ipath, $flag);
+ } elsif (/^--no-split$/) {
+ # ignore option for makeinfo compatibility
} elsif (/^-/) {
usage();
} else {
--
2.27.0
+39
View File
@@ -0,0 +1,39 @@
# DP: Fix gold on mips64 targets.
gold/
2016-08-09 Aurelien Jarno <aurelien@aurel32.net>
* configure.tgt: Add mips64el*-*-*|mips64le*-*-* and mips64*-*-*.
--- a/gold/configure.tgt
+++ b/gold/configure.tgt
@@ -153,6 +153,13 @@ aarch64*-*)
targ_big_endian=false
targ_extra_big_endian=true
;;
+mips*64*el*-*-*|mips*64*le*-*-*)
+ targ_obj=mips
+ targ_machine=EM_MIPS_RS3_LE
+ targ_size=64
+ targ_big_endian=false
+ targ_extra_big_endian=true
+ ;;
mips*el*-*-*|mips*le*-*-*)
targ_obj=mips
targ_machine=EM_MIPS_RS3_LE
@@ -160,6 +167,13 @@ mips*el*-*-*|mips*le*-*-*)
targ_big_endian=false
targ_extra_big_endian=true
;;
+mips*64*-*-*)
+ targ_obj=mips
+ targ_machine=EM_MIPS
+ targ_size=64
+ targ_big_endian=true
+ targ_extra_big_endian=false
+ ;;
mips*-*-*)
targ_obj=mips
targ_machine=EM_MIPS
+19
View File
@@ -0,0 +1,19 @@
--- ./ld/configure.tgt.orig
+++ ./ld/configure.tgt
@@ -541,12 +541,12 @@
;;
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="elf32ltsmipn32 elf32btsmipn32 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
-103
View File
@@ -1,103 +0,0 @@
Patch-Source: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=225df051d3d4cf714d1791b9035966a6686b3f3d;hp=a70d5ba34cb64bbbb7df4f3055cf5b1967bdf61e#patch1
https://sourceware.org/bugzilla/show_bug.cgi?id=25694
--
From: Nelson Chu <nelson@nelson.ba.rivosinc.com>
Date: Thu, 4 May 2023 09:08:50 +0000 (+0800)
Subject: [PR ld/22263][PR ld/25694] RISC-V: Avoid dynamic TLS relocs in PIE.
X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=225df051d3d4cf714d1791b9035966a6686b3f3d;hp=a70d5ba34cb64bbbb7df4f3055cf5b1967bdf61e
[PR ld/22263][PR ld/25694] RISC-V: Avoid dynamic TLS relocs in PIE.
Lots of targets already fixed the TEXTREL problem for TLS in PIE.
* For PR ld/25694,
In the check_reloc, refer to spare and loongarch, they don't need to reserve
any local dynamic reloc for TLS LE in pie/pde, and similar to other targets.
So it seems like riscv was too conservative to estimate the TLS LE before.
Just break and don't goto static_reloc for TLS LE in pie/pde can fix the
TEXTREL problem.
* For PR ld/22263,
The risc-v code for TLS GD/IE in the relocate_section seems same as MIPS port.
So similar to MIPS, pr22570, commits 9143e72c6d4d and 1cb83cac9a89, it seems
also the right way to do the same thing for risc-v.
On risc-v, fixes
FAIL: Build pr22263-1
RISC-V haven't supported the TLS transitions, so will need the same fix (use
bfd_link_dll) in the future.
bfd/
PR ld/22263
PR ld/25694
* elfnn-riscv.c (riscv_elf_check_relocs): Replace bfd_link_pic with
bfd_link_dll for TLS IE. Don't need to reserve the local dynamic
relocation for TLS LE in pie/pde, and report error in pic just like
before.
(riscv_elf_relocate_section): For TLS GD/IE, use bfd_link_dll rather
than !bfd_link_pic in determining the dynamic symbol index. Avoid
the index of -1.
---
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 75af040cf92..762ea231c0b 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -824,7 +824,7 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
break;
case R_RISCV_TLS_GOT_HI20:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
info->flags |= DF_STATIC_TLS;
if (!riscv_elf_record_got_reference (abfd, info, h, r_symndx)
|| !riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_IE))
@@ -920,11 +920,12 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
goto static_reloc;
case R_RISCV_TPREL_HI20:
+ /* This is not allowed in the pic, but okay in pie. */
if (!bfd_link_executable (info))
return bad_static_reloc (abfd, r_type, h);
if (h != NULL)
riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_LE);
- goto static_reloc;
+ break;
case R_RISCV_HI20:
if (bfd_link_pic (info))
@@ -2880,24 +2881,20 @@ riscv_elf_relocate_section (bfd *output_bfd,
if (htab->elf.srelgot == NULL)
abort ();
- if (h != NULL)
- {
- bool dyn, pic;
- dyn = htab->elf.dynamic_sections_created;
- pic = bfd_link_pic (info);
-
- if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, pic, h)
- && (!pic || !SYMBOL_REFERENCES_LOCAL (info, h)))
- indx = h->dynindx;
- }
+ bool dyn = elf_hash_table (info)->dynamic_sections_created;
+ if (h != NULL
+ && h->dynindx != -1
+ && WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h)
+ && (bfd_link_dll (info) || !SYMBOL_REFERENCES_LOCAL (info, h)))
+ indx = h->dynindx;
/* The GOT entries have not been initialized yet. Do it
now, and emit any relocations. */
- if ((bfd_link_pic (info) || indx != 0)
+ if ((bfd_link_dll (info) || indx != 0)
&& (h == NULL
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak))
- need_relocs = true;
+ need_relocs = true;
if (tls_type & GOT_TLS_GD)
{
+44 -104
View File
@@ -2,35 +2,27 @@
# Generator: pmbootstrap aportgen binutils-armv7
# Based on: main/binutils
CTARGET_ARCH=armv7
CTARGET="$(arch_to_hostspec $CTARGET_ARCH)"
pkgname=binutils-armv7
pkgver=2.40
pkgrel=11
pkgver=2.37
pkgrel=4
pkgdesc="Tools necessary to build programs for armv7 targets"
url="https://www.gnu.org/software/binutils/"
makedepends_build="bison flex texinfo"
makedepends_host="zlib-dev jansson-dev zstd-dev"
makedepends="$makedepends_build $makedepends_host"
makedepends="gettext libtool autoconf automake bison texinfo"
arch="x86_64"
license="GPL-2.0-or-later AND LGPL-2.1-or-later AND BSD-3-Clause"
subpackages="binutils-dev binutils-doc"
license="GPL-2.0 GPL-3.0-or-later LGPL-2.0 BSD"
source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
CVE-2023-1972.patch
binutils-ld-fix-static-linking.patch
riscv64-textrels.patch
gold-mips.patch
ld-bfd-mips.patch
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
binutils-mips-disable-assert.patch
bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
defang-no-split.patch
"
builddir="$srcdir/binutils-$pkgver"
if [ -z "$BOOTSTRAP" ]; then
makedepends_host="$makedepends_host jansson-dev zstd-dev"
fi
if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then
subpackages="$subpackages binutils-gold"
subpackages=""
fi
if [ "$CHOST" != "$CTARGET" ]; then
@@ -40,14 +32,6 @@ if [ "$CHOST" != "$CTARGET" ]; then
fi
# secfixes:
# 2.40-r10:
# - CVE-2023-1972
# 2.40-r0:
# - CVE-2023-1579
# 2.39-r2:
# - CVE-2022-38533
# 2.39-r0:
# - CVE-2022-38126
# 2.35.2-r1:
# - CVE-2021-3487
# 2.32-r0:
@@ -58,95 +42,51 @@ fi
# 2.28-r1:
# - CVE-2017-7614
prepare() {
default_prepare
# Remove existing empty man pages to force them to be regenerated.
# Workaround for https://gitlab.alpinelinux.org/alpine/aports/-/issues/13034
find "$builddir" -name '[a-z]*\.[0-9]*' -empty -delete
}
build() {
local _sysroot=/
local _cross_configure="--enable-install-libiberty --enable-shared"
local _arch_configure=""
local _gold_configure="--disable-gold"
local _plugin_configure="--enable-plugins"
if [ "$CHOST" != "$CTARGET" ]; then
_sysroot="$CBUILDROOT"
_cross_configure="--disable-install-libiberty"
_plugin_configure="--disable-plugins"
fi
if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then
_gold_configure="--enable-gold"
fi
if [ "$CTARGET_ARCH" = "x86_64" ]; then
_arch_configure="--enable-targets=x86_64-pep"
fi
if [ "$CTARGET_ARCH" = "riscv64" ]; then
_gold_configure="--disable-gold"
fi
CFLAGS="$CFLAGS -O2" \
CXXFLAGS="$CXXFLAGS -O2" \
./configure \
--build=$CBUILD \
--host=$CHOST \
--target=$CTARGET \
--with-build-sysroot="$CBUILDROOT" \
--with-sysroot=$_sysroot \
_target="$(arch_to_hostspec armv7)"
"$builddir"/configure \
--build="$CBUILD" \
--target=$_target \
--with-lib-path=/usr/lib \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc \
$_arch_configure \
$_cross_configure \
$_gold_configure \
$_plugin_configure \
--disable-gprofng \
--disable-multilib \
--disable-nls \
--disable-werror \
--enable-64-bit-bfd \
--enable-colored-disassembly \
--enable-default-execstack=no \
--enable-default-hash-style=gnu \
--enable-deterministic-archives \
--with-sysroot=/usr/$_target \
--enable-ld=default \
--enable-new-dtags \
--enable-relro \
--enable-threads \
--with-bugurl="https://postmarketos.org/issues" \
--with-mmap \
--with-pic \
--with-system-zlib
--enable-gold=yes \
--enable-plugins \
--enable-deterministic-archives \
--disable-multilib \
--disable-werror \
--disable-nls
make
}
package() {
make install DESTDIR="$pkgdir"
if [ -d "$pkgdir"/usr/lib64 ]; then
mv "$pkgdir"/usr/lib64/* "$pkgdir"/usr/lib/
rmdir "$pkgdir"/usr/lib64
fi
if [ "$CHOST" != "$CTARGET" ]; then
# creating cross tools: remove any files that would conflict
# with the native tools, or other cross tools
rm -r "${pkgdir:?}"/usr/share
rm -f "$pkgdir"/usr/lib/libiberty.a
rm -r "${pkgdir:?}"/usr/lib/bfd-plugins
fi
# remove man, info folders
rm -rf "$pkgdir"/usr/share
# remove files that conflict with non-cross binutils
rm -rf "$pkgdir"/usr/lib/bfd-plugins
}
gold() {
pkgdesc="GNU binutils - gold linker"
if [ -e "$pkgdir"/usr/bin/ld.gold ]; then
amove usr/bin/ld.gold
fi
amove usr/$CTARGET/bin/ld.gold
}
sha512sums="
a37e042523bc46494d99d5637c3f3d8f9956d9477b748b3b1f6d7dfbb8d968ed52c932e88a4e946c6f77b8f48f1e1b360ca54c3d298f17193f3b4963472f6925 binutils-2.40.tar.xz
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
b434e126c4c3f70c02b0a5597a0d75a4ea99b1498552c2d0676005ac0ae171c56cf07a6f6e2faa1381f1f4d4a37043a07d177dd4912f09b61109f103853594b2 CVE-2023-1972.patch
5c11aeef6935860a6819ed3a3c93371f052e52b4bdc5033da36037c1544d013b7f12cb8d561ec954fe7469a68f1b66f1a3cd53d5a3af7293635a90d69edd15e7 binutils-2.37.tar.xz
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch
d138691d953c6f49111601df1731db157d2ecedf1593e37ababb5c12ff10572b5f7982288c81579f4a99097780dbb18d3b457f74daab0f935f59423e69cec56f riscv64-textrels.patch
f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch
314d2ef9071c89940aa6c8118e8a1e2f191a5d0a4bf596da1ad9cc84f884d8bc7dea8bd7b9fc3f8f1bddd3fd41c6eb017e1e804044b3bf084df1ed9e6e095e2d ld-bfd-mips.patch
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
609cd90d8b334eb309f586b17b9d335a08d3dbb6def7c3eb5c010028fcb681674031e5b9d853aa7a39a50304356a86afc184b85562b3f228f8197f4d29395c8f binutils-mips-disable-assert.patch
10a0074583d2cc4598710c7e434ba7088da074b105f4f5e951fc61af7150ad62adf60a7c98f6fd13b1771f169e45a5a1ef618240c6893d3f0f3d93fd768a03c6 bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
4652f092c9376f0cb7fd6c72cb37ff7c15c1c6e3408fac79329b7f41a7925c98eb35989a9a040682130988a36401901d6d95afa44f0ce50caa85ee478db6bf03 defang-no-split.patch
"
-37
View File
@@ -1,37 +0,0 @@
Patch-Source: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57;hp=f2f9bde5cde7ff34ed0a4c4682a211d402aa1086
https://sourceware.org/bugzilla/show_bug.cgi?id=30285
--
From: Nick Clifton <nickc@redhat.com>
Date: Thu, 30 Mar 2023 09:10:09 +0000 (+0100)
Subject: Fix an illegal memory access when an accessing a zer0-lengthverdef table.
X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57;hp=f2f9bde5cde7ff34ed0a4c4682a211d402aa1086
Fix an illegal memory access when an accessing a zer0-lengthverdef table.
PR 30285
* elf.c (_bfd_elf_slurp_version_tables): Fail if no version definitions are allocated.
---
diff --git a/bfd/elf.c b/bfd/elf.c
index 027d0143735..185028cbd97 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9030,6 +9030,9 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
bfd_set_error (bfd_error_file_too_big);
goto error_return_verdef;
}
+
+ if (amt == 0)
+ goto error_return_verdef;
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verdef == NULL)
goto error_return_verdef;
@@ -9133,6 +9136,8 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
bfd_set_error (bfd_error_file_too_big);
goto error_return;
}
+ if (amt == 0)
+ goto error_return;
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verdef == NULL)
goto error_return;
@@ -0,0 +1,234 @@
Upstream: yes
URL: https://sourceware.org/bugzilla/show_bug.cgi?id=28138
From 1c611b40e6bfc8029bff7696814330b5bc0ee5c0 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 26 Jul 2021 05:59:55 -0700
Subject: [PATCH] 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)
---
bfd/plugin.c | 8 +++++++
ld/testsuite/ld-plugin/lto.exp | 34 ++++++++++++++++++++++++++++++
ld/testsuite/ld-plugin/pr28138-1.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-2.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-3.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-4.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-5.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-6.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-7.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138.c | 20 ++++++++++++++++++
10 files changed, 104 insertions(+)
create mode 100644 ld/testsuite/ld-plugin/pr28138-1.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-2.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-3.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-4.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-5.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-6.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-7.c
create mode 100644 ld/testsuite/ld-plugin/pr28138.c
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 6cfa2b66470..3bab8febe88 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -291,6 +291,14 @@ bfd_plugin_close_file_descriptor (bfd *abfd, int fd)
&& !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. */
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index def69e43ab3..999d911ce6a 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -687,6 +687,40 @@ if { [is_elf_format] && [check_lto_shared_available] } {
}
}
+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"]
diff --git a/ld/testsuite/ld-plugin/pr28138-1.c b/ld/testsuite/ld-plugin/pr28138-1.c
new file mode 100644
index 00000000000..51d119e1642
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-1.c
@@ -0,0 +1,6 @@
+extern int a0(void);
+int
+a1(void)
+{
+ return 1 + a0();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-2.c b/ld/testsuite/ld-plugin/pr28138-2.c
new file mode 100644
index 00000000000..1120cd797e9
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-2.c
@@ -0,0 +1,6 @@
+extern int a1(void);
+int
+a2(void)
+{
+ return 1 + a1();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-3.c b/ld/testsuite/ld-plugin/pr28138-3.c
new file mode 100644
index 00000000000..ec464947ee6
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-3.c
@@ -0,0 +1,6 @@
+extern int a2(void);
+int
+a3(void)
+{
+ return 1 + a2();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-4.c b/ld/testsuite/ld-plugin/pr28138-4.c
new file mode 100644
index 00000000000..475701b2c5c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-4.c
@@ -0,0 +1,6 @@
+extern int a3(void);
+int
+a4(void)
+{
+ return 1 + a3();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-5.c b/ld/testsuite/ld-plugin/pr28138-5.c
new file mode 100644
index 00000000000..e24f86c363e
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-5.c
@@ -0,0 +1,6 @@
+extern int a4(void);
+int
+a5(void)
+{
+ return 1 + a4();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-6.c b/ld/testsuite/ld-plugin/pr28138-6.c
new file mode 100644
index 00000000000..b5b938bdb21
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-6.c
@@ -0,0 +1,6 @@
+extern int a5(void);
+int
+a6(void)
+{
+ return 1 + a5();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-7.c b/ld/testsuite/ld-plugin/pr28138-7.c
new file mode 100644
index 00000000000..4ef75bf0f0c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-7.c
@@ -0,0 +1,6 @@
+extern int a6(void);
+int
+a7(void)
+{
+ return 1 + a6();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138.c b/ld/testsuite/ld-plugin/pr28138.c
new file mode 100644
index 00000000000..68252c9f382
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+extern int a7(void);
+
+int
+a0(void)
+{
+ return 0;
+}
+
+int
+main()
+{
+ if (a7() == 7)
+ {
+ printf ("PASS\n");
+ return 0;
+ }
+ return 1;
+}
--
2.27.0
@@ -0,0 +1,14 @@
diff -urN binutils-2.35.2.orig/bfd/elfxx-mips.c binutils-2.35.2/bfd/elfxx-mips.c
--- binutils-2.35.2.orig/bfd/elfxx-mips.c 2021-01-30 01:38:03.000000000 -0700
+++ binutils-2.35.2/bfd/elfxx-mips.c 2021-05-13 17:35:34.706913601 -0600
@@ -6744,8 +6744,10 @@
in the relocation. */
if (h != NULL && ! SYMBOL_REFERENCES_LOCAL (info, &h->root))
{
+#if 0
BFD_ASSERT (htab->root.target_os == is_vxworks
|| h->global_got_area != GGA_NONE);
+#endif
indx = h->root.dynindx;
if (SGI_COMPAT (output_bfd))
defined_p = h->root.def_regular;
@@ -0,0 +1,38 @@
From 2dad02b6d46eef438cbd14d8511487b056628a38 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <siarheit@google.com>
Date: Mon, 26 Jul 2021 22:51:18 +0100
Subject: [PATCH 1/1] texi2pod.pl: add no-op --no-split option support
[PR28144]
Change 2faf902da ("generate single html manual page by default")
added use of --no-split option to makeinfo. binutils reuses
makeinfo options for texi2pod.pl wrapper. Unsupported option
led to silent manpage truncation.
The change adds no-op option support.
etc/
PR 28144
* texi2pod.pl: Handle no-op --no-split option.
(cherry picked from commit 96a7037cd8573cf065aa6b12baca68696f96d9ca)
---
etc/texi2pod.pl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/etc/texi2pod.pl b/etc/texi2pod.pl
index 11f70d156be..dcf2b437640 100644
--- a/etc/texi2pod.pl
+++ b/etc/texi2pod.pl
@@ -59,6 +59,8 @@ while ($_ = shift) {
$flag = shift;
}
push (@ipath, $flag);
+ } elsif (/^--no-split$/) {
+ # ignore option for makeinfo compatibility
} elsif (/^-/) {
usage();
} else {
--
2.27.0
+39
View File
@@ -0,0 +1,39 @@
# DP: Fix gold on mips64 targets.
gold/
2016-08-09 Aurelien Jarno <aurelien@aurel32.net>
* configure.tgt: Add mips64el*-*-*|mips64le*-*-* and mips64*-*-*.
--- a/gold/configure.tgt
+++ b/gold/configure.tgt
@@ -153,6 +153,13 @@ aarch64*-*)
targ_big_endian=false
targ_extra_big_endian=true
;;
+mips*64*el*-*-*|mips*64*le*-*-*)
+ targ_obj=mips
+ targ_machine=EM_MIPS_RS3_LE
+ targ_size=64
+ targ_big_endian=false
+ targ_extra_big_endian=true
+ ;;
mips*el*-*-*|mips*le*-*-*)
targ_obj=mips
targ_machine=EM_MIPS_RS3_LE
@@ -160,6 +167,13 @@ mips*el*-*-*|mips*le*-*-*)
targ_big_endian=false
targ_extra_big_endian=true
;;
+mips*64*-*-*)
+ targ_obj=mips
+ targ_machine=EM_MIPS
+ targ_size=64
+ targ_big_endian=true
+ targ_extra_big_endian=false
+ ;;
mips*-*-*)
targ_obj=mips
targ_machine=EM_MIPS
+19
View File
@@ -0,0 +1,19 @@
--- ./ld/configure.tgt.orig
+++ ./ld/configure.tgt
@@ -541,12 +541,12 @@
;;
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="elf32ltsmipn32 elf32btsmipn32 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
-103
View File
@@ -1,103 +0,0 @@
Patch-Source: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=225df051d3d4cf714d1791b9035966a6686b3f3d;hp=a70d5ba34cb64bbbb7df4f3055cf5b1967bdf61e#patch1
https://sourceware.org/bugzilla/show_bug.cgi?id=25694
--
From: Nelson Chu <nelson@nelson.ba.rivosinc.com>
Date: Thu, 4 May 2023 09:08:50 +0000 (+0800)
Subject: [PR ld/22263][PR ld/25694] RISC-V: Avoid dynamic TLS relocs in PIE.
X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=225df051d3d4cf714d1791b9035966a6686b3f3d;hp=a70d5ba34cb64bbbb7df4f3055cf5b1967bdf61e
[PR ld/22263][PR ld/25694] RISC-V: Avoid dynamic TLS relocs in PIE.
Lots of targets already fixed the TEXTREL problem for TLS in PIE.
* For PR ld/25694,
In the check_reloc, refer to spare and loongarch, they don't need to reserve
any local dynamic reloc for TLS LE in pie/pde, and similar to other targets.
So it seems like riscv was too conservative to estimate the TLS LE before.
Just break and don't goto static_reloc for TLS LE in pie/pde can fix the
TEXTREL problem.
* For PR ld/22263,
The risc-v code for TLS GD/IE in the relocate_section seems same as MIPS port.
So similar to MIPS, pr22570, commits 9143e72c6d4d and 1cb83cac9a89, it seems
also the right way to do the same thing for risc-v.
On risc-v, fixes
FAIL: Build pr22263-1
RISC-V haven't supported the TLS transitions, so will need the same fix (use
bfd_link_dll) in the future.
bfd/
PR ld/22263
PR ld/25694
* elfnn-riscv.c (riscv_elf_check_relocs): Replace bfd_link_pic with
bfd_link_dll for TLS IE. Don't need to reserve the local dynamic
relocation for TLS LE in pie/pde, and report error in pic just like
before.
(riscv_elf_relocate_section): For TLS GD/IE, use bfd_link_dll rather
than !bfd_link_pic in determining the dynamic symbol index. Avoid
the index of -1.
---
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 75af040cf92..762ea231c0b 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -824,7 +824,7 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
break;
case R_RISCV_TLS_GOT_HI20:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
info->flags |= DF_STATIC_TLS;
if (!riscv_elf_record_got_reference (abfd, info, h, r_symndx)
|| !riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_IE))
@@ -920,11 +920,12 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
goto static_reloc;
case R_RISCV_TPREL_HI20:
+ /* This is not allowed in the pic, but okay in pie. */
if (!bfd_link_executable (info))
return bad_static_reloc (abfd, r_type, h);
if (h != NULL)
riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_LE);
- goto static_reloc;
+ break;
case R_RISCV_HI20:
if (bfd_link_pic (info))
@@ -2880,24 +2881,20 @@ riscv_elf_relocate_section (bfd *output_bfd,
if (htab->elf.srelgot == NULL)
abort ();
- if (h != NULL)
- {
- bool dyn, pic;
- dyn = htab->elf.dynamic_sections_created;
- pic = bfd_link_pic (info);
-
- if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, pic, h)
- && (!pic || !SYMBOL_REFERENCES_LOCAL (info, h)))
- indx = h->dynindx;
- }
+ bool dyn = elf_hash_table (info)->dynamic_sections_created;
+ if (h != NULL
+ && h->dynindx != -1
+ && WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h)
+ && (bfd_link_dll (info) || !SYMBOL_REFERENCES_LOCAL (info, h)))
+ indx = h->dynindx;
/* The GOT entries have not been initialized yet. Do it
now, and emit any relocations. */
- if ((bfd_link_pic (info) || indx != 0)
+ if ((bfd_link_dll (info) || indx != 0)
&& (h == NULL
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak))
- need_relocs = true;
+ need_relocs = true;
if (tls_type & GOT_TLS_GD)
{
@@ -1,55 +0,0 @@
From bbf05b742fde518fb97c789b043fe0d3aaf549f0 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Tue, 21 Sep 2021 14:53:13 +0000
Subject: [PATCH] Revert "PR25882, .gnu.attributes are not checked for shared
libraries"
This revert is needed to avoid wrongly tagging objects with the incompatible
IBM long double ABI, which is not supported by musl and will result in
linking errors if used.
This reverts commit a8acd6eeb6dc2cc5460ece90f90ebe36b56b20ba.
---
bfd/elf32-tic6x.c | 3 ---
ld/ldlang.c | 10 ++++------
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index 5754f3cb860..3ad1d612749 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -3735,9 +3735,6 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
case Tag_ABI_PIC:
case Tag_ABI_PID:
- /* Don't transfer these tags from dynamic objects. */
- if ((ibfd->flags & DYNAMIC) != 0)
- continue;
if (out_attr[i].i > in_attr[i].i)
out_attr[i].i = in_attr[i].i;
break;
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 37b64c89ee1..f13beaef9d9 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -7071,13 +7071,11 @@ lang_check (void)
bfd_printable_name (input_bfd), input_bfd,
bfd_printable_name (link_info.output_bfd));
}
-
- /* If the input bfd has no contents, it shouldn't set the
- private data of the output bfd. */
- else if (!file->flags.just_syms
- && ((input_bfd->flags & DYNAMIC) != 0
- || bfd_count_sections (input_bfd) != 0))
+ else if (bfd_count_sections (input_bfd))
{
+ /* If the input bfd has no contents, it shouldn't set the
+ private data of the output bfd. */
+
bfd_error_handler_type pfn = NULL;
/* If we aren't supposed to warn about mismatched input
--
2.33.0
-152
View File
@@ -1,152 +0,0 @@
# Automatically generated aport, do not edit!
# Generator: pmbootstrap aportgen binutils-riscv64
# Based on: main/binutils
CTARGET_ARCH=riscv64
CTARGET="$(arch_to_hostspec $CTARGET_ARCH)"
pkgname=binutils-riscv64
pkgver=2.40
pkgrel=11
pkgdesc="Tools necessary to build programs for riscv64 targets"
url="https://www.gnu.org/software/binutils/"
makedepends_build="bison flex texinfo"
makedepends_host="zlib-dev jansson-dev zstd-dev"
makedepends="$makedepends_build $makedepends_host"
arch="x86_64"
license="GPL-2.0-or-later AND LGPL-2.1-or-later AND BSD-3-Clause"
subpackages="binutils-dev binutils-doc"
source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
CVE-2023-1972.patch
binutils-ld-fix-static-linking.patch
riscv64-textrels.patch
"
builddir="$srcdir/binutils-$pkgver"
if [ -z "$BOOTSTRAP" ]; then
makedepends_host="$makedepends_host jansson-dev zstd-dev"
fi
if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then
subpackages="$subpackages binutils-gold"
fi
if [ "$CHOST" != "$CTARGET" ]; then
pkgname="binutils-$CTARGET_ARCH"
subpackages=""
sonameprefix="binutils:"
fi
# secfixes:
# 2.40-r10:
# - CVE-2023-1972
# 2.40-r0:
# - CVE-2023-1579
# 2.39-r2:
# - CVE-2022-38533
# 2.39-r0:
# - CVE-2022-38126
# 2.35.2-r1:
# - CVE-2021-3487
# 2.32-r0:
# - CVE-2018-19931
# - CVE-2018-19932
# - CVE-2018-20002
# - CVE-2018-20712
# 2.28-r1:
# - CVE-2017-7614
build() {
local _sysroot=/
local _cross_configure="--enable-install-libiberty --enable-shared"
local _arch_configure=""
local _gold_configure="--disable-gold"
local _plugin_configure="--enable-plugins"
if [ "$CHOST" != "$CTARGET" ]; then
_sysroot="$CBUILDROOT"
_cross_configure="--disable-install-libiberty"
_plugin_configure="--disable-plugins"
fi
if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then
_gold_configure="--enable-gold"
fi
if [ "$CTARGET_ARCH" = "x86_64" ]; then
_arch_configure="--enable-targets=x86_64-pep"
fi
if [ "$CTARGET_ARCH" = "riscv64" ]; then
_gold_configure="--disable-gold"
fi
CFLAGS="$CFLAGS -O2" \
CXXFLAGS="$CXXFLAGS -O2" \
./configure \
--build=$CBUILD \
--host=$CHOST \
--target=$CTARGET \
--with-build-sysroot="$CBUILDROOT" \
--with-sysroot=$_sysroot \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc \
$_arch_configure \
$_cross_configure \
$_gold_configure \
$_plugin_configure \
--disable-gprofng \
--disable-multilib \
--disable-nls \
--disable-werror \
--enable-64-bit-bfd \
--enable-colored-disassembly \
--enable-default-execstack=no \
--enable-default-hash-style=gnu \
--enable-deterministic-archives \
--enable-ld=default \
--enable-new-dtags \
--enable-relro \
--enable-threads \
--with-bugurl="https://postmarketos.org/issues" \
--with-mmap \
--with-pic \
--with-system-zlib
make
}
package() {
make install DESTDIR="$pkgdir"
if [ -d "$pkgdir"/usr/lib64 ]; then
mv "$pkgdir"/usr/lib64/* "$pkgdir"/usr/lib/
rmdir "$pkgdir"/usr/lib64
fi
if [ "$CHOST" != "$CTARGET" ]; then
# creating cross tools: remove any files that would conflict
# with the native tools, or other cross tools
rm -r "${pkgdir:?}"/usr/share
rm -f "$pkgdir"/usr/lib/libiberty.a
rm -r "${pkgdir:?}"/usr/lib/bfd-plugins
fi
}
gold() {
pkgdesc="GNU binutils - gold linker"
if [ -e "$pkgdir"/usr/bin/ld.gold ]; then
amove usr/bin/ld.gold
fi
amove usr/$CTARGET/bin/ld.gold
}
sha512sums="
a37e042523bc46494d99d5637c3f3d8f9956d9477b748b3b1f6d7dfbb8d968ed52c932e88a4e946c6f77b8f48f1e1b360ca54c3d298f17193f3b4963472f6925 binutils-2.40.tar.xz
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
b434e126c4c3f70c02b0a5597a0d75a4ea99b1498552c2d0676005ac0ae171c56cf07a6f6e2faa1381f1f4d4a37043a07d177dd4912f09b61109f103853594b2 CVE-2023-1972.patch
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch
d138691d953c6f49111601df1731db157d2ecedf1593e37ababb5c12ff10572b5f7982288c81579f4a99097780dbb18d3b457f74daab0f935f59423e69cec56f riscv64-textrels.patch
"
@@ -1,37 +0,0 @@
Patch-Source: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57;hp=f2f9bde5cde7ff34ed0a4c4682a211d402aa1086
https://sourceware.org/bugzilla/show_bug.cgi?id=30285
--
From: Nick Clifton <nickc@redhat.com>
Date: Thu, 30 Mar 2023 09:10:09 +0000 (+0100)
Subject: Fix an illegal memory access when an accessing a zer0-lengthverdef table.
X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57;hp=f2f9bde5cde7ff34ed0a4c4682a211d402aa1086
Fix an illegal memory access when an accessing a zer0-lengthverdef table.
PR 30285
* elf.c (_bfd_elf_slurp_version_tables): Fail if no version definitions are allocated.
---
diff --git a/bfd/elf.c b/bfd/elf.c
index 027d0143735..185028cbd97 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9030,6 +9030,9 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
bfd_set_error (bfd_error_file_too_big);
goto error_return_verdef;
}
+
+ if (amt == 0)
+ goto error_return_verdef;
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verdef == NULL)
goto error_return_verdef;
@@ -9133,6 +9136,8 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
bfd_set_error (bfd_error_file_too_big);
goto error_return;
}
+ if (amt == 0)
+ goto error_return;
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verdef == NULL)
goto error_return;
@@ -1,46 +0,0 @@
This fixes static linking for our hardened toolchain
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index e8126cb..9532bfb 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -235,8 +235,8 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then
SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))"
SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))"
- CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors"
- DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors"
+ CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .ctors"
+ DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .dtors"
else
SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))"
SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))"
@@ -270,15 +270,14 @@ CTOR=".ctors ${CONSTRUCTING-0} :
doesn't matter which directory crtbegin.o
is in. */
- KEEP (*crtbegin.o(.ctors))
- KEEP (*crtbegin?.o(.ctors))
+ KEEP (*crtbegin*.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
- KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
${CONSTRUCTING+${CTOR_END}}
@@ -286,9 +285,8 @@ CTOR=".ctors ${CONSTRUCTING-0} :
DTOR=".dtors ${CONSTRUCTING-0} :
{
${CONSTRUCTING+${DTOR_START}}
- KEEP (*crtbegin.o(.dtors))
- KEEP (*crtbegin?.o(.dtors))
- KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
+ KEEP (*crtbegin*.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
${CONSTRUCTING+${DTOR_END}}
@@ -1,103 +0,0 @@
Patch-Source: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=225df051d3d4cf714d1791b9035966a6686b3f3d;hp=a70d5ba34cb64bbbb7df4f3055cf5b1967bdf61e#patch1
https://sourceware.org/bugzilla/show_bug.cgi?id=25694
--
From: Nelson Chu <nelson@nelson.ba.rivosinc.com>
Date: Thu, 4 May 2023 09:08:50 +0000 (+0800)
Subject: [PR ld/22263][PR ld/25694] RISC-V: Avoid dynamic TLS relocs in PIE.
X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=225df051d3d4cf714d1791b9035966a6686b3f3d;hp=a70d5ba34cb64bbbb7df4f3055cf5b1967bdf61e
[PR ld/22263][PR ld/25694] RISC-V: Avoid dynamic TLS relocs in PIE.
Lots of targets already fixed the TEXTREL problem for TLS in PIE.
* For PR ld/25694,
In the check_reloc, refer to spare and loongarch, they don't need to reserve
any local dynamic reloc for TLS LE in pie/pde, and similar to other targets.
So it seems like riscv was too conservative to estimate the TLS LE before.
Just break and don't goto static_reloc for TLS LE in pie/pde can fix the
TEXTREL problem.
* For PR ld/22263,
The risc-v code for TLS GD/IE in the relocate_section seems same as MIPS port.
So similar to MIPS, pr22570, commits 9143e72c6d4d and 1cb83cac9a89, it seems
also the right way to do the same thing for risc-v.
On risc-v, fixes
FAIL: Build pr22263-1
RISC-V haven't supported the TLS transitions, so will need the same fix (use
bfd_link_dll) in the future.
bfd/
PR ld/22263
PR ld/25694
* elfnn-riscv.c (riscv_elf_check_relocs): Replace bfd_link_pic with
bfd_link_dll for TLS IE. Don't need to reserve the local dynamic
relocation for TLS LE in pie/pde, and report error in pic just like
before.
(riscv_elf_relocate_section): For TLS GD/IE, use bfd_link_dll rather
than !bfd_link_pic in determining the dynamic symbol index. Avoid
the index of -1.
---
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 75af040cf92..762ea231c0b 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -824,7 +824,7 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
break;
case R_RISCV_TLS_GOT_HI20:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
info->flags |= DF_STATIC_TLS;
if (!riscv_elf_record_got_reference (abfd, info, h, r_symndx)
|| !riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_IE))
@@ -920,11 +920,12 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
goto static_reloc;
case R_RISCV_TPREL_HI20:
+ /* This is not allowed in the pic, but okay in pie. */
if (!bfd_link_executable (info))
return bad_static_reloc (abfd, r_type, h);
if (h != NULL)
riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_LE);
- goto static_reloc;
+ break;
case R_RISCV_HI20:
if (bfd_link_pic (info))
@@ -2880,24 +2881,20 @@ riscv_elf_relocate_section (bfd *output_bfd,
if (htab->elf.srelgot == NULL)
abort ();
- if (h != NULL)
- {
- bool dyn, pic;
- dyn = htab->elf.dynamic_sections_created;
- pic = bfd_link_pic (info);
-
- if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, pic, h)
- && (!pic || !SYMBOL_REFERENCES_LOCAL (info, h)))
- indx = h->dynindx;
- }
+ bool dyn = elf_hash_table (info)->dynamic_sections_created;
+ if (h != NULL
+ && h->dynindx != -1
+ && WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h)
+ && (bfd_link_dll (info) || !SYMBOL_REFERENCES_LOCAL (info, h)))
+ indx = h->dynindx;
/* The GOT entries have not been initialized yet. Do it
now, and emit any relocations. */
- if ((bfd_link_pic (info) || indx != 0)
+ if ((bfd_link_dll (info) || indx != 0)
&& (h == NULL
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak))
- need_relocs = true;
+ need_relocs = true;
if (tls_type & GOT_TLS_GD)
{
+3 -3
View File
@@ -7,8 +7,8 @@ if [ -z "$(type -t arch_to_hostspec)" ]; then
fi
pkgname=busybox-static-aarch64
pkgver=1.36.1
pkgrel=0
pkgver=1.35.0
pkgrel=2
_arch="aarch64"
_mirror="http://dl-4.alpinelinux.org/alpine/"
@@ -32,5 +32,5 @@ package() {
}
sha512sums="
d4977cf4654bb5659d4e6d91785832d3fd418403b70f1619c26aa305839d64c131c6389979793896af0fb0d9e8fc2b99537dbeb65133465d7d983576902dff34 busybox-static-1.36.1-r0-aarch64-edge.apk
5c78ac835881f3647d2f434ba79f42e2098ac59c1a32d78b11062ea1bdc07f79dd19f51dd19aeb04853525c87759c3cfc2ad255ad65e1e193bd25d1d7d8143fc busybox-static-1.35.0-r2-aarch64-edge.apk
"
+3 -3
View File
@@ -7,8 +7,8 @@ if [ -z "$(type -t arch_to_hostspec)" ]; then
fi
pkgname=busybox-static-armhf
pkgver=1.36.1
pkgrel=0
pkgver=1.35.0
pkgrel=2
_arch="armhf"
_mirror="http://dl-4.alpinelinux.org/alpine/"
@@ -32,5 +32,5 @@ package() {
}
sha512sums="
eece41953046c99029ec4a0707c1fd4270d43b497f05cf63070deef376fc28f61bcdfa8b9f34e23305ba459a633909eb1682fbe183206b69dea8be3742479ae7 busybox-static-1.36.1-r0-armhf-edge.apk
66eafcdcacfa2bc1bfe777add65e2471994932c2ddb68e30852e87d5d1a26e294e33b888547a4d05c281a9c2d570f0f992cb77a68de367086c055ea285ff31b6 busybox-static-1.35.0-r2-armhf-edge.apk
"
+3 -3
View File
@@ -7,8 +7,8 @@ if [ -z "$(type -t arch_to_hostspec)" ]; then
fi
pkgname=busybox-static-armv7
pkgver=1.36.1
pkgrel=0
pkgver=1.35.0
pkgrel=2
_arch="armv7"
_mirror="http://dl-4.alpinelinux.org/alpine/"
@@ -32,5 +32,5 @@ package() {
}
sha512sums="
29df2ea5d83535632308524064dbb43bf9ed147ab1112bed76b1fc70b519d7dc3e4083c51527e80129a455a001479569641b710f58fdad8538852061d4880660 busybox-static-1.36.1-r0-armv7-edge.apk
ce9099e461f7bb48a5312d00f7dc7b7e863c612925d8d0b8d1c0e6d7689a2d6b9eac47c7627f53eaa8350742d884a457b8fa65b8758ff62e349688141dcdd907 busybox-static-1.35.0-r2-armv7-edge.apk
"
+4 -4
View File
@@ -1,14 +1,14 @@
From 3e5acbe356124aa5d8dde0635d652c065a553e7d Mon Sep 17 00:00:00 2001
From e289226f5f16db14ca549efb41ca82accfe7ea8a Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Fri, 26 Jan 2018 20:32:50 +0000
Subject: [PATCH 01/33] posix_memalign
Subject: [PATCH] posix_memalign
---
gcc/config/i386/pmm_malloc.h | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/gcc/config/i386/pmm_malloc.h b/gcc/config/i386/pmm_malloc.h
index 3527283693b..c4071b64b53 100644
index 1b0bfe37852..d7b2b19bb3c 100644
--- a/gcc/config/i386/pmm_malloc.h
+++ b/gcc/config/i386/pmm_malloc.h
@@ -27,12 +27,13 @@
@@ -38,5 +38,5 @@ index 3527283693b..c4071b64b53 100644
else
return NULL;
--
2.40.1
2.34.1
@@ -1,7 +1,7 @@
From f986a4a1224fa7d452b415d690aead8d356a7eae Mon Sep 17 00:00:00 2001
From 48be81c9accb55c3c5ee683c84fa1f908bb18764 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 29 Mar 2013 08:59:00 +0400
Subject: [PATCH 02/33] gcc: poison-system-directories
Subject: [PATCH] gcc: poison-system-directories
Add /sw/include and /opt/include based on the original
zecke-no-host-includes.patch patch. The original patch checked for
@@ -21,15 +21,15 @@ Upstream-Status: Pending
gcc/configure | 16 ++++++++++++++++
gcc/configure.ac | 10 ++++++++++
gcc/doc/invoke.texi | 9 +++++++++
gcc/gcc.cc | 2 ++
gcc/incpath.cc | 21 +++++++++++++++++++++
gcc/gcc.c | 2 ++
gcc/incpath.c | 21 +++++++++++++++++++++
7 files changed, 68 insertions(+)
diff --git a/gcc/common.opt b/gcc/common.opt
index 862c474d3c8..64c4277c991 100644
index a75b44ee47e..d15105a73f3 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -711,6 +711,10 @@ Wreturn-local-addr
@@ -683,6 +683,10 @@ Wreturn-local-addr
Common Var(warn_return_local_addr) Init(1) Warning
Warn about returning a pointer/reference to a local or temporary variable.
@@ -41,10 +41,10 @@ index 862c474d3c8..64c4277c991 100644
Common Var(warn_shadow) Warning
Warn when one variable shadows another. Same as -Wshadow=global.
diff --git a/gcc/config.in b/gcc/config.in
index 4cad077bfbe..0679fbbf4c6 100644
index 2de5a463315..059c818c895 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -236,6 +236,12 @@
@@ -218,6 +218,12 @@
#endif
@@ -58,10 +58,10 @@ index 4cad077bfbe..0679fbbf4c6 100644
optimizer and back end) to be checked for dynamic type safety at runtime.
This is quite expensive. */
diff --git a/gcc/configure b/gcc/configure
index c7b26d1927d..8c46369f73f 100755
index 708328e1670..4b977e313b5 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -1026,6 +1026,7 @@ enable_maintainer_mode
@@ -1020,6 +1020,7 @@ enable_maintainer_mode
enable_link_mutex
enable_link_serialization
enable_version_specific_runtime_libs
@@ -69,7 +69,7 @@ index c7b26d1927d..8c46369f73f 100755
enable_plugin
enable_host_shared
enable_libquadmath_support
@@ -1788,6 +1789,8 @@ Optional Features:
@@ -1782,6 +1783,8 @@ Optional Features:
--enable-version-specific-runtime-libs
specify that runtime libraries should be installed
in a compiler-specific directory
@@ -78,7 +78,7 @@ index c7b26d1927d..8c46369f73f 100755
--enable-plugin enable plugin support
--enable-host-shared build host code as shared libraries
--disable-libquadmath-support
@@ -31753,6 +31756,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
@@ -31790,6 +31793,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
fi
@@ -99,10 +99,10 @@ index c7b26d1927d..8c46369f73f 100755
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 09082e8ccae..5504bf6eb01 100644
index df1c9cc3200..5461bab88a9 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -7292,6 +7292,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
@@ -7311,6 +7311,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
[specify that runtime libraries should be
installed in a compiler-specific directory])])
@@ -120,37 +120,37 @@ index 09082e8ccae..5504bf6eb01 100644
AC_SUBST(subdirs)
AC_SUBST(srcdir)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index c0c3ad14515..7cdd5bfa952 100644
index 5a4b3c6c234..9d1126e9751 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -384,6 +384,7 @@ Objective-C and Objective-C++ Dialects}.
-Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded
-Wparentheses -Wno-pedantic-ms-format
-Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast
+-Wno-poison-system-directories
-Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls
-Wrestrict -Wno-return-local-addr -Wreturn-type
-Wno-scalar-storage-order -Wsequence-point
@@ -8424,6 +8425,14 @@ made up of data only and thus requires no special treatment. But, for
@@ -369,6 +369,7 @@ Objective-C and Objective-C++ Dialects}.
-Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol
-Wparentheses -Wno-pedantic-ms-format @gol
-Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol
+-Wno-poison-system-directories @gol
-Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol
-Wrestrict -Wno-return-local-addr -Wreturn-type @gol
-Wno-scalar-storage-order -Wsequence-point @gol
@@ -7727,6 +7728,14 @@ made up of data only and thus requires no special treatment. But, for
most targets, it is made up of code and thus requires the stack to be
made executable in order for the program to work properly.
+@opindex Wno-poison-system-directories
+@item -Wno-poison-system-directories
+@opindex Wno-poison-system-directories
+Do not warn for @option{-I} or @option{-L} options using system
+directories such as @file{/usr/include} when cross compiling. This
+option is intended for use in chroot environments when such
+directories contain the correct headers and libraries for the target
+system rather than the host.
+
@item -Wfloat-equal
@opindex Wfloat-equal
@opindex Wno-float-equal
@item -Wfloat-equal
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 16bb07f2cdc..33b56e721d2 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1146,6 +1146,8 @@ proper position among the other output files. */
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 8ba410c9e17..a83ba34ac4b 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1152,6 +1152,8 @@ proper position among the other output files. */
"%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
"%X %{o*} %{e*} %{N} %{n} %{r}\
%{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
@@ -159,10 +159,10 @@ index 16bb07f2cdc..33b56e721d2 100644
%{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \
VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \
%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
diff --git a/gcc/incpath.cc b/gcc/incpath.cc
index 4d44321183f..0f3f071b44c 100644
--- a/gcc/incpath.cc
+++ b/gcc/incpath.cc
diff --git a/gcc/incpath.c b/gcc/incpath.c
index 446d280321d..fbfc0ce03b8 100644
--- a/gcc/incpath.c
+++ b/gcc/incpath.c
@@ -26,6 +26,7 @@
#include "intl.h"
#include "incpath.h"
@@ -171,7 +171,7 @@ index 4d44321183f..0f3f071b44c 100644
/* Microsoft Windows does not natively support inodes.
VMS has non-numeric inodes. */
@@ -399,6 +400,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
@@ -395,6 +396,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
}
fprintf (stderr, _("End of search list.\n"));
}
@@ -199,5 +199,5 @@ index 4d44321183f..0f3f071b44c 100644
/* Use given -I paths for #include "..." but not #include <...>, and
--
2.40.1
2.34.1
@@ -1,7 +1,7 @@
From 31e2b60000e779ef775daa306120eabcf987852a Mon Sep 17 00:00:00 2001
From 767b97ca271e82601a435015190fd15bfb28ae12 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:45:49 +0000
Subject: [PATCH 03/33] specs: turn on -Wl,-z,now by default
Subject: [PATCH] specs: turn on -Wl,-z,now by default
Previously, we also used to turn on -z relro here, but we now build
binutils with --enable-relro, which is functionally equivalent.
@@ -10,28 +10,28 @@ Binutils does not appear to have a similar option for enabling -z
now by default.
---
gcc/doc/invoke.texi | 3 +++
gcc/gcc.cc | 1 +
gcc/gcc.c | 1 +
2 files changed, 4 insertions(+)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 7cdd5bfa952..158b7bcb81e 100644
index 9d1126e9751..4b8335bbd1f 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -17959,6 +17959,9 @@ For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
@@ -15920,6 +15920,9 @@ For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
linker. When using the GNU linker, you can also get the same effect with
@option{-Wl,-Map=output.map}.
+NOTE: In Alpine Linux, for LDFLAGS, the option
+@option{-Wl,-z,now} is used. To disable, use @option{-Wl,-z,nonow}.
+
@opindex u
@item -u @var{symbol}
@opindex u
Pretend the symbol @var{symbol} is undefined, to force linking of
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 33b56e721d2..f82fae23c22 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1144,6 +1144,7 @@ proper position among the other output files. */
diff --git a/gcc/gcc.c b/gcc/gcc.c
index a83ba34ac4b..faf9ce76b3d 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1150,6 +1150,7 @@ proper position among the other output files. */
"%{flto|flto=*:%<fcompare-debug*} \
%{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC \
"%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
@@ -40,5 +40,5 @@ index 33b56e721d2..f82fae23c22 100644
%{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
%{Wno-poison-system-directories:--no-poison-system-directories} \
--
2.40.1
2.34.1
@@ -1,19 +1,19 @@
From 3b910da7d1e81bdd953e6d9ec82020e7b120353b Mon Sep 17 00:00:00 2001
From b8abbd503d1be992bf1d204f0e6de5260fcdf533 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:46:22 +0000
Subject: [PATCH 04/33] Turn on -D_FORTIFY_SOURCE=2 by default for C, C++,
ObjC, ObjC++, if the optimization level is > 0
Subject: [PATCH] Turn on -D_FORTIFY_SOURCE=2 by default for C, C++, ObjC,
ObjC++, if the optimization level is > 0
---
gcc/c-family/c-cppbuiltin.cc | 4 ++++
gcc/doc/invoke.texi | 6 ++++++
gcc/c-family/c-cppbuiltin.c | 4 ++++
gcc/doc/invoke.texi | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 5d64625fcd7..868d69506e4 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1546,6 +1546,10 @@ c_cpp_builtins (cpp_reader *pfile)
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 9f993c4aff2..7db314195ff 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -1421,6 +1421,10 @@ c_cpp_builtins (cpp_reader *pfile)
builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);
@@ -25,10 +25,10 @@ index 5d64625fcd7..868d69506e4 100644
if (flag_gnu89_inline)
cpp_define (pfile, "__GNUC_GNU_INLINE__");
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 158b7bcb81e..cc9972f907b 100644
index 4b8335bbd1f..833164e0a2b 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -11866,6 +11866,12 @@ also turns on the following optimization flags:
@@ -10224,6 +10224,12 @@ also turns on the following optimization flags:
Please note the warning under @option{-fgcse} about
invoking @option{-O2} on programs that use computed gotos.
@@ -38,9 +38,9 @@ index 158b7bcb81e..cc9972f907b 100644
+functions. To disable, specify either @option{-U_FORTIFY_SOURCE} or
+@option{-D_FORTIFY_SOURCE=0}.
+
@opindex O3
@item -O3
@opindex O3
Optimize yet more. @option{-O3} turns on all optimizations specified
--
2.40.1
2.34.1
@@ -1,8 +1,8 @@
From 9c3a2882b1932296ccb1d0ed2900cf046f998a26 Mon Sep 17 00:00:00 2001
From 1837896f54bd318788c1ba6dbd19c3efe147ba20 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:46:56 +0000
Subject: [PATCH 05/33] On linux targets pass --as-needed by default to the
linker, but always link the sanitizer libraries with --no-as-needed.
Subject: [PATCH] On linux targets pass --as-needed by default to the linker,
but always link the sanitizer libraries with --no-as-needed.
---
gcc/config/aarch64/aarch64-linux.h | 1 +
@@ -18,11 +18,11 @@ Subject: [PATCH 05/33] On linux targets pass --as-needed by default to the
gcc/config/rs6000/sysv4.h | 2 +-
gcc/config/s390/linux.h | 2 +-
gcc/config/sparc/linux.h | 2 +-
gcc/gcc.cc | 28 ++++++++++++++++++++--------
gcc/gcc.c | 28 ++++++++++++++++++++--------
14 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index 4277f03da2a..b131983a546 100644
index 7f2529a2a1d..b097e1688aa 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -35,6 +35,7 @@
@@ -34,7 +34,7 @@ index 4277f03da2a..b131983a546 100644
%{shared:-shared} \
%{symbolic:-Bsymbolic} \
diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h
index 03f783f2ad1..d946e700dda 100644
index c1dae8ca2cf..a87dc740171 100644
--- a/gcc/config/alpha/linux-elf.h
+++ b/gcc/config/alpha/linux-elf.h
@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3. If not see
@@ -47,7 +47,7 @@ index 03f783f2ad1..d946e700dda 100644
%{shared:-shared} \
%{!shared: \
diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
index 7b7b7cbbe14..49c050c6f2c 100644
index 0c1c4e70b6b..8b581afacdd 100644
--- a/gcc/config/arm/linux-elf.h
+++ b/gcc/config/arm/linux-elf.h
@@ -70,6 +70,7 @@
@@ -59,7 +59,7 @@ index 7b7b7cbbe14..49c050c6f2c 100644
SUBTARGET_EXTRA_LINK_SPEC
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index eda8010b133..b26b17f2f2a 100644
index 5ebbf42a13d..902378e1bad 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -136,7 +136,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
@@ -69,9 +69,9 @@ index eda8010b133..b26b17f2f2a 100644
- LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
+ LD_DYNAMIC_OPTION "}}%{!static-libasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lasan %{fuse-ld=gold:--as-needed;:--pop-state}}"
#undef LIBHWASAN_EARLY_SPEC
#define LIBHWASAN_EARLY_SPEC "%{!shared:libhwasan_preinit%O%s} " \
"%{static-libhwasan:%{!shared:" \
@@ -146,12 +146,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define LIBHWASAN_EARLY_SPEC "%{static-libhwasan:%{!shared:" \
LD_STATIC_OPTION " --whole-archive -lhwasan --no-whole-archive " \
@@ -145,12 +145,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \
"%{static-libtsan:%{!shared:" \
LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
@@ -87,7 +87,7 @@ index eda8010b133..b26b17f2f2a 100644
#undef TARGET_F951_OPTIONS
diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
index a79b739089d..e0752673dff 100644
index a23e7ab3eb7..12ac8cb93a9 100644
--- a/gcc/config/i386/gnu-user.h
+++ b/gcc/config/i386/gnu-user.h
@@ -68,7 +68,7 @@ along with GCC; see the file COPYING3. If not see
@@ -100,7 +100,7 @@ index a79b739089d..e0752673dff 100644
%{!static: \
%{!static-pie: \
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index 3b63b99acf6..759bf0db86f 100644
index f3e25b1412a..712b0f1c30e 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -56,6 +56,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
@@ -112,7 +112,7 @@ index 3b63b99acf6..759bf0db86f 100644
%{!shared: \
%{!static: \
diff --git a/gcc/config/ia64/linux.h b/gcc/config/ia64/linux.h
index 5dfd428aa17..02656dad7fc 100644
index ac40c3dfd3f..6e19e25c35a 100644
--- a/gcc/config/ia64/linux.h
+++ b/gcc/config/ia64/linux.h
@@ -58,7 +58,7 @@ do { \
@@ -125,7 +125,7 @@ index 5dfd428aa17..02656dad7fc 100644
%{!shared: \
%{!static: \
diff --git a/gcc/config/mips/gnu-user.h b/gcc/config/mips/gnu-user.h
index a4e5380b589..3cc61bce69f 100644
index a390bcece83..be0ee289367 100644
--- a/gcc/config/mips/gnu-user.h
+++ b/gcc/config/mips/gnu-user.h
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see
@@ -137,10 +137,10 @@ index a4e5380b589..3cc61bce69f 100644
%{!static: \
%{rdynamic:-export-dynamic} \
diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
index 2fdfd930cf2..16503482ec2 100644
index fce5b896e6e..ee29979dd34 100644
--- a/gcc/config/riscv/linux.h
+++ b/gcc/config/riscv/linux.h
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see
@@ -58,6 +58,7 @@ along with GCC; see the file COPYING3. If not see
"%{mabi=ilp32:_ilp32}"
#define LINK_SPEC "\
@@ -149,10 +149,10 @@ index 2fdfd930cf2..16503482ec2 100644
%{mno-relax:--no-relax} \
%{mbig-endian:-EB} \
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 9e457033d11..08016bf224d 100644
index e3f2cd254f6..43499ed29cf 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -377,13 +377,13 @@ extern int dot_symbols;
@@ -374,13 +374,13 @@ extern int dot_symbols;
" -m elf64ppc")
#endif
@@ -169,10 +169,10 @@ index 9e457033d11..08016bf224d 100644
%{rdynamic:-export-dynamic} \
-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index ae932fc22f0..c8ff0c6dc8e 100644
index 510abe169c5..3c1f3a8ec5d 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -780,7 +780,7 @@ GNU_USER_TARGET_CC1_SPEC
@@ -789,7 +789,7 @@ GNU_USER_TARGET_CC1_SPEC
#define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
#endif
@@ -182,7 +182,7 @@ index ae932fc22f0..c8ff0c6dc8e 100644
-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h
index 02aa1edaff8..64df5801134 100644
index daa48fdfc2b..2fcfc5d770f 100644
--- a/gcc/config/s390/linux.h
+++ b/gcc/config/s390/linux.h
@@ -82,7 +82,7 @@ along with GCC; see the file COPYING3. If not see
@@ -195,7 +195,7 @@ index 02aa1edaff8..64df5801134 100644
%{!shared: \
%{static:-static} \
diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index 0e33b3cac2c..c2f44546e62 100644
index 2550d7ee8f0..7596d0b2757 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -81,7 +81,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
@@ -207,11 +207,11 @@ index 0e33b3cac2c..c2f44546e62 100644
%{!mno-relax:%{!r:-relax}} \
%{!shared: \
%{!static: \
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index f82fae23c22..da6417dd0d1 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -754,8 +754,11 @@ proper position among the other output files. */
diff --git a/gcc/gcc.c b/gcc/gcc.c
index faf9ce76b3d..1ad5da6d769 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -737,8 +737,11 @@ proper position among the other output files. */
#ifdef LIBASAN_EARLY_SPEC
#define LIBASAN_SPEC STATIC_LIBASAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
@@ -225,7 +225,7 @@ index f82fae23c22..da6417dd0d1 100644
STATIC_LIBASAN_LIBS
#else
#define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS
@@ -790,8 +793,11 @@ proper position among the other output files. */
@@ -773,8 +776,11 @@ proper position among the other output files. */
#ifdef LIBTSAN_EARLY_SPEC
#define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
@@ -239,7 +239,7 @@ index f82fae23c22..da6417dd0d1 100644
STATIC_LIBTSAN_LIBS
#else
#define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS
@@ -808,8 +814,11 @@ proper position among the other output files. */
@@ -791,8 +797,11 @@ proper position among the other output files. */
#ifdef LIBLSAN_EARLY_SPEC
#define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS
#elif defined(HAVE_LD_STATIC_DYNAMIC)
@@ -253,7 +253,7 @@ index f82fae23c22..da6417dd0d1 100644
STATIC_LIBLSAN_LIBS
#else
#define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS
@@ -824,8 +833,11 @@ proper position among the other output files. */
@@ -807,8 +816,11 @@ proper position among the other output files. */
#define STATIC_LIBUBSAN_LIBS \
" %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}"
#ifdef HAVE_LD_STATIC_DYNAMIC
@@ -268,5 +268,5 @@ index f82fae23c22..da6417dd0d1 100644
#else
#define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS
--
2.40.1
2.34.1
@@ -1,17 +1,17 @@
From 288cb2be3abe07dcf2737ed3ac07e93573262bc4 Mon Sep 17 00:00:00 2001
From 1ba693868db68bef5178fd797c9e7d2cc4128182 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:47:43 +0000
Subject: [PATCH 06/33] Enable -Wformat and -Wformat-security by default.
Subject: [PATCH] Enable -Wformat and -Wformat-security by default.
---
gcc/c-family/c.opt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index a75038930ae..b98726f33ed 100644
index 2005b783c68..c5c6af427cc 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -704,7 +704,7 @@ Warn about function calls with format strings that write past the end
@@ -637,7 +637,7 @@ Warn about function calls with format strings that write past the end
of the destination region. Same as -Wformat-overflow=1.
Wformat-security
@@ -20,7 +20,7 @@ index a75038930ae..b98726f33ed 100644
Warn about possible security problems with format functions.
Wformat-signedness
@@ -725,7 +725,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++
@@ -658,7 +658,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++
Warn about zero-length formats.
Wformat=
@@ -30,5 +30,5 @@ index a75038930ae..b98726f33ed 100644
Wformat-overflow=
--
2.40.1
2.34.1
@@ -1,17 +1,17 @@
From 93e44f7c7b1f11c1f714d6c384b0d39a191ac18a Mon Sep 17 00:00:00 2001
From eb2f1f7d7c503959279a7317af7b9a7625eecc6e Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:48:24 +0000
Subject: [PATCH 07/33] Enable -Wtrampolines by default.
Subject: [PATCH] Enable -Wtrampolines by default.
---
gcc/common.opt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index 64c4277c991..c24839d32bc 100644
index d15105a73f3..29f9504cb68 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -803,7 +803,7 @@ Common Var(warn_system_headers) Warning
@@ -775,7 +775,7 @@ Common Var(warn_system_headers) Warning
Do not suppress warnings from system headers.
Wtrampolines
@@ -19,7 +19,7 @@ index 64c4277c991..c24839d32bc 100644
+Common Var(warn_trampolines) Init(1) Warning
Warn whenever a trampoline is generated.
Wtrivial-auto-var-init
Wtype-limits
--
2.40.1
2.34.1
@@ -1,19 +1,19 @@
From 7aa93d6d9a63c7bedf1e033f6d040e95038537e7 Mon Sep 17 00:00:00 2001
From 7a4086e83e3abbf2c20b7211e2a2c0bf00f25ff8 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:49:40 +0000
Subject: [PATCH 08/33] Disable ssp on -nostdlib, -nodefaultlibs and
-ffreestanding Change the buffer size.
Subject: [PATCH] Disable ssp on -nostdlib, -nodefaultlibs and -ffreestanding
Change the buffer size.
---
gcc/gcc.cc | 8 +++++++-
gcc/gcc.c | 8 +++++++-
gcc/params.opt | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index da6417dd0d1..b5a6f200635 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -983,6 +983,12 @@ proper position among the other output files. */
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 1ad5da6d769..99314032ec2 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -989,6 +989,12 @@ proper position among the other output files. */
#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
#endif
@@ -26,7 +26,7 @@ index da6417dd0d1..b5a6f200635 100644
#ifndef LINK_SSP_SPEC
#ifdef TARGET_LIBC_PROVIDES_SSP
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
@@ -1282,7 +1288,7 @@ static const char *cc1_options =
@@ -1288,7 +1294,7 @@ static const char *cc1_options =
%{-version:--version}\
%{-help=*:--help=%*}\
%{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
@@ -36,10 +36,10 @@ index da6417dd0d1..b5a6f200635 100644
%{fprofile-arcs|fprofile-generate*|coverage:\
%{!fprofile-update=single:\
diff --git a/gcc/params.opt b/gcc/params.opt
index 823cdb2ff85..5b096899b40 100644
index 8ba281b4cfa..bab39cdf8a2 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -1006,7 +1006,7 @@ Common Joined UInteger Var(param_ssa_name_def_chain_limit) Init(512) Param Optim
@@ -946,7 +946,7 @@ Common Joined UInteger Var(param_ssa_name_def_chain_limit) Init(512) Param Optim
The maximum number of SSA_NAME assignments to follow in determining a value.
-param=ssp-buffer-size=
@@ -49,5 +49,5 @@ index 823cdb2ff85..5b096899b40 100644
-param=stack-clash-protection-guard-size=
--
2.40.1
2.34.1
@@ -1,8 +1,8 @@
From e44b295b5b0b917c0b47085f60466a37f890e1c7 Mon Sep 17 00:00:00 2001
From 1c38cbf1f75066c3acc145f449f1fbd0b5de7968 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:50:33 +0000
Subject: [PATCH 09/33] Ensure that msgfmt doesn't encounter problems during
gcc bootstrapping.
Subject: [PATCH] Ensure that msgfmt doesn't encounter problems during gcc
bootstrapping.
Solves error messages like the following:
@@ -26,7 +26,7 @@ https://bugs.gentoo.org/295480
2 files changed, 2 insertions(+)
diff --git a/libstdc++-v3/po/Makefile.am b/libstdc++-v3/po/Makefile.am
index 12d34910830..61b13762b71 100644
index ab716ff04ea..e595268d9fc 100644
--- a/libstdc++-v3/po/Makefile.am
+++ b/libstdc++-v3/po/Makefile.am
@@ -38,6 +38,7 @@ MSGFMT = msgfmt
@@ -38,10 +38,10 @@ index 12d34910830..61b13762b71 100644
all-local: all-local-$(USE_NLS)
diff --git a/libstdc++-v3/po/Makefile.in b/libstdc++-v3/po/Makefile.in
index 8e93445acd2..d6ff06e5ddb 100644
index 8edd2e05639..63f61fcf96f 100644
--- a/libstdc++-v3/po/Makefile.in
+++ b/libstdc++-v3/po/Makefile.in
@@ -561,6 +561,7 @@ uninstall-am:
@@ -553,6 +553,7 @@ uninstall-am:
.po.mo:
@@ -50,5 +50,5 @@ index 8e93445acd2..d6ff06e5ddb 100644
all-local: all-local-$(USE_NLS)
--
2.40.1
2.34.1
@@ -1,14 +1,14 @@
From f041dcd8f775e03b85a49e3aeef0870e2333b10e Mon Sep 17 00:00:00 2001
From e4c844ce0c1c355c2d1cf6a6e1595030b8ce2a5e Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:52:07 +0000
Subject: [PATCH 10/33] Don't declare asprintf if defined as a macro.
Subject: [PATCH] Don't declare asprintf if defined as a macro.
---
include/libiberty.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/libiberty.h b/include/libiberty.h
index 1d5c779fcff..19e3cb1e31c 100644
index f4c0fe11d6f..cf4b1043e4d 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -652,8 +652,11 @@ extern void *bsearch_r (const void *, const void *,
@@ -24,5 +24,5 @@ index 1d5c779fcff..19e3cb1e31c 100644
/* Like asprintf but allocates memory without fail. This works like
xmalloc. */
--
2.40.1
2.34.1
@@ -1,17 +1,17 @@
From 6fc13fce114648b1a64e658b469a4697382d18bb Mon Sep 17 00:00:00 2001
From 79309ae34db26104ec85f6af31a4a8133142fe6d Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:53:00 +0000
Subject: [PATCH 11/33] libiberty: copy PIC objects during build process
Subject: [PATCH] libiberty: copy PIC objects during build process
---
libiberty/Makefile.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 72608f3e4a7..58356884728 100644
index 4f1213b983b..d0224649d30 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -265,6 +265,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
@@ -264,6 +264,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
$(AR) $(AR_FLAGS) $(TARGETLIB) \
$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
$(RANLIB) $(TARGETLIB); \
@@ -20,5 +20,5 @@ index 72608f3e4a7..58356884728 100644
else true; fi
--
2.40.1
2.34.1
@@ -0,0 +1,33 @@
From fdf5ef3d1e61625cb96647d5bdc4ca0a32d287ec Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:53:36 +0000
Subject: [PATCH] libitm: disable FORTIFY
---
libitm/configure.tgt | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libitm/configure.tgt b/libitm/configure.tgt
index a3d84896cc5..ecb281d5919 100644
--- a/libitm/configure.tgt
+++ b/libitm/configure.tgt
@@ -47,6 +47,16 @@ if test "$gcc_cv_have_tls" = yes ; then
esac
fi
+# FIXME: error: inlining failed in call to always_inline
+# ‘int vfprintf(FILE*, const char*, __va_list_tag*)’
+# : function body can be overwritten at link time
+# Disable Fortify in libitm for now. #508852
+case "${target}" in
+ *-*-linux*)
+ XCFLAGS="${XCFLAGS} -U_FORTIFY_SOURCE"
+ ;;
+esac
+
# Map the target cpu to an ARCH sub-directory. At the same time,
# work out any special compilation flags as necessary.
case "${target_cpu}" in
--
2.34.1
@@ -1,33 +1,33 @@
From 6a1955bbf49836ad99b23501f42283842e01761b Mon Sep 17 00:00:00 2001
From 9442d683845f63b931374ff81a7d08a31f992135 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Sat, 24 Oct 2015 20:09:53 +0000
Subject: [PATCH 12/33] libgcc_s
Subject: [PATCH] libgcc_s
---
gcc/config/i386/i386-expand.cc | 4 ++--
libgcc/config/i386/cpuinfo.c | 6 +++---
libgcc/config/i386/t-linux | 2 +-
gcc/config/i386/i386-expand.c | 4 ++--
libgcc/config/i386/cpuinfo.c | 6 +++---
libgcc/config/i386/t-linux | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index 0d817fc3f3b..2e99db00db9 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -12691,10 +12691,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index 16765718cc3..4a855b791b9 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -11063,10 +11063,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
{
case IX86_BUILTIN_CPU_INIT:
{
- /* Make it call __cpu_indicator_init in libgcc. */
+ /* Make it call __cpu_indicator_init in libgcc.a. */
- /* Make it call __cpu_indicator_init in libgcc. */
+ /* Make it call __cpu_indicator_init_local in libgcc.a. */
tree call_expr, fndecl, type;
type = build_function_type_list (integer_type_node, NULL_TREE);
type = build_function_type_list (integer_type_node, NULL_TREE);
- fndecl = build_fn_decl ("__cpu_indicator_init", type);
+ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
call_expr = build_call_expr (fndecl, 0);
call_expr = build_call_expr (fndecl, 0);
return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
}
diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
index 50b6d8248a2..724ced402a1 100644
index ef463848f9d..1a3de052c80 100644
--- a/libgcc/config/i386/cpuinfo.c
+++ b/libgcc/config/i386/cpuinfo.c
@@ -63,7 +63,7 @@ __cpu_indicator_init (void)
@@ -53,5 +53,5 @@ index 8506a635790..564296f788e 100644
+HOST_LIBGCC2_CFLAGS += -mlong-double-80 $(CET_FLAGS)
CRTSTUFF_T_CFLAGS += $(CET_FLAGS)
--
2.40.1
2.34.1
@@ -1,7 +1,7 @@
From 558e95aa2b0f3bbf416e1bb572e5f47bddc8601c Mon Sep 17 00:00:00 2001
From 7a3e354de1ab87e992bfdaf858677ca140b80732 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Sat, 7 Nov 2015 02:08:05 +0000
Subject: [PATCH 13/33] nopie
Subject: [PATCH] nopie
---
gcc/configure | 27 +++++++++++++++++++++++++++
@@ -9,10 +9,10 @@ Subject: [PATCH 13/33] nopie
2 files changed, 40 insertions(+)
diff --git a/gcc/configure b/gcc/configure
index 8c46369f73f..e59cbee1767 100755
index 4b977e313b5..592e81e40f6 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -32268,6 +32268,33 @@ fi
@@ -32300,6 +32300,33 @@ fi
$as_echo "$gcc_cv_no_pie" >&6; }
if test "$gcc_cv_no_pie" = "yes"; then
NO_PIE_FLAG="-no-pie"
@@ -47,10 +47,10 @@ index 8c46369f73f..e59cbee1767 100755
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 5504bf6eb01..57268319de1 100644
index 5461bab88a9..1577529ffb7 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -7552,6 +7552,19 @@ AC_CACHE_CHECK([for -no-pie option],
@@ -7571,6 +7571,19 @@ AC_CACHE_CHECK([for -no-pie option],
LDFLAGS="$saved_LDFLAGS"])
if test "$gcc_cv_no_pie" = "yes"; then
NO_PIE_FLAG="-no-pie"
@@ -71,5 +71,5 @@ index 5504bf6eb01..57268319de1 100644
AC_SUBST([NO_PIE_FLAG])
--
2.40.1
2.34.1
@@ -0,0 +1,25 @@
From 9a5417a787c2ba197c0a3002ea7423488bedab0a Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:57:09 +0000
Subject: [PATCH] libffi: use __linux__ instead of __gnu_linux__ for musl
---
libffi/src/closures.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libffi/src/closures.c b/libffi/src/closures.c
index 721ff00ea43..22a699c6340 100644
--- a/libffi/src/closures.c
+++ b/libffi/src/closures.c
@@ -34,7 +34,7 @@
#include <ffi_common.h>
#if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE
-# if __gnu_linux__ && !defined(__ANDROID__)
+# if __linux__ && !defined(__ANDROID__)
/* This macro indicates it may be forbidden to map anonymous memory
with both write and execute permission. Code compiled when this
option is defined will attempt to map such pages once, but if it
--
2.34.1
@@ -0,0 +1,425 @@
From ecc537cc597fba87f00d3128fddd5f2a17e7d222 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:57:51 +0000
Subject: [PATCH] dlang: update zlib binding
---
libphobos/src/std/zlib.d | 266 ++++++++++++++++++++++++++++-----------
1 file changed, 196 insertions(+), 70 deletions(-)
diff --git a/libphobos/src/std/zlib.d b/libphobos/src/std/zlib.d
index e6cce240fd5..bd2fe37ebec 100644
--- a/libphobos/src/std/zlib.d
+++ b/libphobos/src/std/zlib.d
@@ -1,7 +1,7 @@
// Written in the D programming language.
/**
- * Compress/decompress data using the $(HTTP www._zlib.net, _zlib library).
+ * Compress/decompress data using the $(HTTP www.zlib.net, zlib library).
*
* Examples:
*
@@ -43,12 +43,12 @@
* References:
* $(HTTP en.wikipedia.org/wiki/Zlib, Wikipedia)
*
- * Copyright: Copyright Digital Mars 2000 - 2011.
+ * Copyright: Copyright The D Language Foundation 2000 - 2011.
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: $(HTTP digitalmars.com, Walter Bright)
- * Source: $(PHOBOSSRC std/_zlib.d)
+ * Source: $(PHOBOSSRC std/zlib.d)
*/
-/* Copyright Digital Mars 2000 - 2011.
+/* Copyright The D Language Foundation 2000 - 2011.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
@@ -75,9 +75,9 @@ enum
class ZlibException : Exception
{
- this(int errnum)
- { string msg;
-
+ private static string getmsg(int errnum) nothrow @nogc pure @safe
+ {
+ string msg;
switch (errnum)
{
case Z_STREAM_END: msg = "stream end"; break;
@@ -90,7 +90,12 @@ class ZlibException : Exception
case Z_VERSION_ERROR: msg = "version error"; break;
default: msg = "unknown error"; break;
}
- super(msg);
+ return msg;
+ }
+
+ this(int errnum)
+ {
+ super(getmsg(errnum));
}
}
@@ -104,7 +109,7 @@ class ZlibException : Exception
* buf = buffer containing input data
*
* Returns:
- * A $(D uint) checksum for the provided input data and starting checksum
+ * A `uint` checksum for the provided input data and starting checksum
*
* See_Also:
* $(LINK http://en.wikipedia.org/wiki/Adler-32)
@@ -147,7 +152,7 @@ uint adler32(uint adler, const(void)[] buf)
* buf = buffer containing input data
*
* Returns:
- * A $(D uint) checksum for the provided input data and starting checksum
+ * A `uint` checksum for the provided input data and starting checksum
*
* See_Also:
* $(LINK http://en.wikipedia.org/wiki/Cyclic_redundancy_check)
@@ -191,13 +196,14 @@ uint crc32(uint crc, const(void)[] buf)
ubyte[] compress(const(void)[] srcbuf, int level)
in
{
- assert(-1 <= level && level <= 9);
+ assert(-1 <= level && level <= 9, "Compression level needs to be within [-1, 9].");
}
-body
+do
{
import core.memory : GC;
+ import std.array : uninitializedArray;
auto destlen = srcbuf.length + ((srcbuf.length + 1023) / 1024) + 12;
- auto destbuf = new ubyte[destlen];
+ auto destbuf = uninitializedArray!(ubyte[])(destlen);
auto err = etc.c.zlib.compress2(destbuf.ptr, &destlen, cast(ubyte *) srcbuf.ptr, srcbuf.length, level);
if (err)
{
@@ -276,7 +282,7 @@ void[] uncompress(const(void)[] srcbuf, size_t destlen = 0u, int winbits = 15)
throw new ZlibException(err);
}
}
- assert(0);
+ assert(0, "Unreachable code");
}
@system unittest
@@ -370,9 +376,9 @@ class Compress
this(int level, HeaderFormat header = HeaderFormat.deflate)
in
{
- assert(1 <= level && level <= 9);
+ assert(1 <= level && level <= 9, "Legal compression level are in [1, 9].");
}
- body
+ do
{
this.level = level;
this.gzip = header == HeaderFormat.gzip;
@@ -406,6 +412,7 @@ class Compress
const(void)[] compress(const(void)[] buf)
{
import core.memory : GC;
+ import std.array : uninitializedArray;
int err;
ubyte[] destbuf;
@@ -420,7 +427,7 @@ class Compress
inited = 1;
}
- destbuf = new ubyte[zs.avail_in + buf.length];
+ destbuf = uninitializedArray!(ubyte[])(zs.avail_in + buf.length);
zs.next_out = destbuf.ptr;
zs.avail_out = to!uint(destbuf.length);
@@ -461,9 +468,10 @@ class Compress
void[] flush(int mode = Z_FINISH)
in
{
- assert(mode == Z_FINISH || mode == Z_SYNC_FLUSH || mode == Z_FULL_FLUSH);
+ assert(mode == Z_FINISH || mode == Z_SYNC_FLUSH || mode == Z_FULL_FLUSH,
+ "Mode must be either Z_FINISH, Z_SYNC_FLUSH or Z_FULL_FLUSH.");
}
- body
+ do
{
import core.memory : GC;
ubyte[] destbuf;
@@ -523,6 +531,7 @@ class UnCompress
z_stream zs;
int inited;
int done;
+ bool inputEnded;
size_t destbufsize;
HeaderFormat format;
@@ -571,16 +580,16 @@ class UnCompress
const(void)[] uncompress(const(void)[] buf)
in
{
- assert(!done);
+ assert(!done, "Buffer has been flushed.");
}
- body
+ do
{
+ if (inputEnded || !buf.length)
+ return null;
+
import core.memory : GC;
+ import std.array : uninitializedArray;
int err;
- ubyte[] destbuf;
-
- if (buf.length == 0)
- return null;
if (!inited)
{
@@ -598,26 +607,152 @@ class UnCompress
if (!destbufsize)
destbufsize = to!uint(buf.length) * 2;
- destbuf = new ubyte[zs.avail_in * 2 + destbufsize];
- zs.next_out = destbuf.ptr;
- zs.avail_out = to!uint(destbuf.length);
-
- if (zs.avail_in)
- buf = zs.next_in[0 .. zs.avail_in] ~ cast(ubyte[]) buf;
+ auto destbuf = uninitializedArray!(ubyte[])(destbufsize);
+ size_t destFill;
zs.next_in = cast(ubyte*) buf.ptr;
zs.avail_in = to!uint(buf.length);
- err = inflate(&zs, Z_NO_FLUSH);
- if (err != Z_STREAM_END && err != Z_OK)
+ while (true)
{
- GC.free(destbuf.ptr);
- error(err);
+ auto oldAvailIn = zs.avail_in;
+
+ zs.next_out = destbuf[destFill .. $].ptr;
+ zs.avail_out = to!uint(destbuf.length - destFill);
+
+ err = inflate(&zs, Z_NO_FLUSH);
+ if (err == Z_STREAM_END)
+ {
+ inputEnded = true;
+ break;
+ }
+ else if (err != Z_OK)
+ {
+ GC.free(destbuf.ptr);
+ error(err);
+ }
+ else if (!zs.avail_in)
+ break;
+
+ /*
+ According to the zlib manual inflate() stops when either there's
+ no more data to uncompress or the output buffer is full
+ So at this point, the output buffer is too full
+ */
+
+ destFill = destbuf.length;
+
+ if (destbuf.capacity)
+ {
+ if (destbuf.length < destbuf.capacity)
+ destbuf.length = destbuf.capacity;
+ else
+ {
+ auto newLength = GC.extend(destbuf.ptr, destbufsize, destbufsize);
+
+ if (newLength && destbuf.length < destbuf.capacity)
+ destbuf.length = destbuf.capacity;
+ else
+ destbuf.length += destbufsize;
+ }
+ }
+ else
+ destbuf.length += destbufsize;
}
+
destbuf.length = destbuf.length - zs.avail_out;
return destbuf;
}
+ // Test for issues 3191 and 9505
+ @system unittest
+ {
+ import std.algorithm.comparison;
+ import std.array;
+ import std.file;
+ import std.zlib;
+
+ // Data that can be easily compressed
+ ubyte[1024] originalData;
+
+ // This should yield a compression ratio of at least 1/2
+ auto compressedData = compress(originalData, 9);
+ assert(compressedData.length < originalData.length / 2,
+ "The compression ratio is too low to accurately test this situation");
+
+ auto chunkSize = compressedData.length / 4;
+ assert(chunkSize < compressedData.length,
+ "The length of the compressed data is too small to accurately test this situation");
+
+ auto decompressor = new UnCompress();
+ ubyte[originalData.length] uncompressedData;
+ ubyte[] reusedBuf;
+ int progress;
+
+ reusedBuf.length = chunkSize;
+
+ for (int i = 0; i < compressedData.length; i += chunkSize)
+ {
+ auto len = min(chunkSize, compressedData.length - i);
+ // simulate reading from a stream in small chunks
+ reusedBuf[0 .. len] = compressedData[i .. i + len];
+
+ // decompress using same input buffer
+ auto chunk = decompressor.uncompress(reusedBuf);
+ assert(progress + chunk.length <= originalData.length,
+ "The uncompressed result is bigger than the original data");
+
+ uncompressedData[progress .. progress + chunk.length] = cast(const ubyte[]) chunk[];
+ progress += chunk.length;
+ }
+
+ auto chunk = decompressor.flush();
+ assert(progress + chunk.length <= originalData.length,
+ "The uncompressed result is bigger than the original data");
+
+ uncompressedData[progress .. progress + chunk.length] = cast(const ubyte[]) chunk[];
+ progress += chunk.length;
+
+ assert(progress == originalData.length,
+ "The uncompressed and the original data sizes differ");
+ assert(originalData[] == uncompressedData[],
+ "The uncompressed and the original data differ");
+ }
+
+ @system unittest
+ {
+ ubyte[1024] invalidData;
+ auto decompressor = new UnCompress();
+
+ try
+ {
+ auto uncompressedData = decompressor.uncompress(invalidData);
+ }
+ catch (ZlibException e)
+ {
+ assert(e.msg == "data error");
+ return;
+ }
+
+ assert(false, "Corrupted data didn't result in an error");
+ }
+
+ @system unittest
+ {
+ ubyte[2014] originalData = void;
+ auto compressedData = compress(originalData, 9);
+
+ auto decompressor = new UnCompress();
+ auto uncompressedData = decompressor.uncompress(compressedData ~ cast(ubyte[]) "whatever");
+
+ assert(originalData.length == uncompressedData.length,
+ "The uncompressed and the original data sizes differ");
+ assert(originalData[] == uncompressedData[],
+ "The uncompressed and the original data differ");
+ assert(!decompressor.uncompress("whatever").length,
+ "Compression continued after the end");
+ }
+
/**
* Decompress and return any remaining data.
* The returned data should be appended to that returned by uncompress().
@@ -626,49 +761,40 @@ class UnCompress
void[] flush()
in
{
- assert(!done);
+ assert(!done, "Buffer has been flushed before.");
}
out
{
- assert(done);
+ assert(done, "Flushing failed.");
}
- body
+ do
{
- import core.memory : GC;
- ubyte[] extra;
- ubyte[] destbuf;
- int err;
-
done = 1;
- if (!inited)
- return null;
+ return null;
+ }
- L1:
- destbuf = new ubyte[zs.avail_in * 2 + 100];
- zs.next_out = destbuf.ptr;
- zs.avail_out = to!uint(destbuf.length);
+ /// Returns true if all input data has been decompressed and no further data
+ /// can be decompressed (inflate() returned Z_STREAM_END)
+ @property bool empty() const
+ {
+ return inputEnded;
+ }
- err = etc.c.zlib.inflate(&zs, Z_NO_FLUSH);
- if (err == Z_OK && zs.avail_out == 0)
- {
- extra ~= destbuf;
- goto L1;
- }
- if (err != Z_STREAM_END)
- {
- GC.free(destbuf.ptr);
- if (err == Z_OK)
- err = Z_BUF_ERROR;
- error(err);
- }
- destbuf = destbuf.ptr[0 .. zs.next_out - destbuf.ptr];
- err = etc.c.zlib.inflateEnd(&zs);
- inited = 0;
- if (err)
- error(err);
- if (extra.length)
- destbuf = extra ~ destbuf;
- return destbuf;
+ ///
+ @system unittest
+ {
+ // some random data
+ ubyte[1024] originalData = void;
+
+ // append garbage data (or don't, this works in both cases)
+ auto compressedData = cast(ubyte[]) compress(originalData) ~ cast(ubyte[]) "whatever";
+
+ auto decompressor = new UnCompress();
+ auto uncompressedData = decompressor.uncompress(compressedData);
+
+ assert(uncompressedData[] == originalData[],
+ "The uncompressed and the original data differ");
+ assert(decompressor.empty, "The UnCompressor reports not being done");
}
}
--
2.34.1
@@ -1,31 +0,0 @@
From 064afc74f18f2a00771fc2600029a713b8708845 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Fri, 21 Aug 2020 07:03:00 +0000
Subject: [PATCH 17/33] Alpine musl package provides libssp_nonshared.a. We
link to it unconditionally, as otherwise we get link failures if some objects
are -fstack-protector built and final link happens with -fno-stack-protector.
This seems to be the common case when bootstrapping gcc, the piepatches do
not seem to fully fix the crosstoolchain and bootstrap sequence wrt.
stack-protector flag usage.
---
gcc/gcc.cc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index b5a6f200635..6cbb726599b 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -991,8 +991,7 @@ proper position among the other output files. */
#ifndef LINK_SSP_SPEC
#ifdef TARGET_LIBC_PROVIDES_SSP
-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
- "|fstack-protector-strong|fstack-protector-explicit:}"
+#define LINK_SSP_SPEC "-lssp_nonshared"
#else
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
"|fstack-protector-strong|fstack-protector-explicit" \
--
2.40.1
@@ -0,0 +1,24 @@
From 273edfbf9845a349cec0643c23fff5a740c76f78 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Thu, 6 Jan 2022 03:18:32 +0000
Subject: [PATCH] dlang: use libucontext on mips64
---
libphobos/configure.tgt | 1 +
1 file changed, 1 insertion(+)
diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt
index 0643daeb613..b74d9fb3f25 100644
--- a/libphobos/configure.tgt
+++ b/libphobos/configure.tgt
@@ -38,6 +38,7 @@ case "${target}" in
;;
mips*-*-linux*)
LIBPHOBOS_SUPPORTED=yes
+ LIBDRUNTIME_NEEDS_UCONTEXT=yes
;;
power*-*-freebsd*)
LIBPHOBOS_SUPPORTED=yes
--
2.34.1
@@ -0,0 +1,38 @@
From 602c9c669e8270f51b8c9c07c3b8840d3cc5d5e4 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Thu, 6 Jan 2022 03:19:12 +0000
Subject: [PATCH] dlang: libdruntime: define fcntl.h constants for mips64
---
libphobos/libdruntime/core/sys/posix/fcntl.d | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d
index 59df921ba41..9ee9f943948 100644
--- a/libphobos/libdruntime/core/sys/posix/fcntl.d
+++ b/libphobos/libdruntime/core/sys/posix/fcntl.d
@@ -871,6 +871,21 @@ else version (CRuntime_Musl)
F_SETLKW = 7,
}
}
+ else version (MIPS_Any)
+ {
+ enum
+ {
+ O_DIRECTORY = 0x010000, // octal 0200000
+ O_NOFOLLOW = 0x020000, // octal 0400000
+ O_DIRECT = 0x008000, // octal 0100000
+ O_LARGEFILE = 0x002000, // octal 0020000
+ O_TMPFILE = 0x410000, // octal 020200000
+
+ F_GETLK = 33,
+ F_SETLK = 34,
+ F_SETLKW = 35,
+ }
+ }
else
static assert(0, "Platform not supported");
--
2.34.1
@@ -1,14 +1,14 @@
From ecad19db42776c536bd4f6033ec1891ffae03720 Mon Sep 17 00:00:00 2001
From 94f4f85904f1c042e4d0c0ac855143129d58fdbd Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:59:16 +0000
Subject: [PATCH 14/33] ada: fix shared linking
Subject: [PATCH] ada: fix shared linking
---
gcc/ada/link.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gcc/ada/link.c b/gcc/ada/link.c
index f2126441208..22cfa9c641f 100644
index 5cd5ef64f56..1c611a82cab 100644
--- a/gcc/ada/link.c
+++ b/gcc/ada/link.c
@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir = "lib";
@@ -38,5 +38,5 @@ index f2126441208..22cfa9c641f 100644
unsigned char __gnat_objlist_file_supported = 1;
const char *__gnat_object_library_extension = ".a";
--
2.40.1
2.34.1
@@ -1,17 +1,17 @@
From 8500b4cdd039c16a02a8acabd124b92865871979 Mon Sep 17 00:00:00 2001
From dac504eb0d50d751ac558efaf84d37716e9ee05b Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:59:43 +0000
Subject: [PATCH 15/33] build: fix CXXFLAGS_FOR_BUILD passing
Subject: [PATCH] build: fix CXXFLAGS_FOR_BUILD passing
---
Makefile.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/Makefile.in b/Makefile.in
index 06a9398e172..6ff2b3f9925 100644
index 047be0255e2..426949aa91c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -178,6 +178,7 @@ BUILD_EXPORTS = \
@@ -170,6 +170,7 @@ BUILD_EXPORTS = \
# built for the build system to override those in BASE_FLAGS_TO_PASS.
EXTRA_BUILD_FLAGS = \
CFLAGS="$(CFLAGS_FOR_BUILD)" \
@@ -20,5 +20,5 @@ index 06a9398e172..6ff2b3f9925 100644
# This is the list of directories to built for the host system.
--
2.40.1
2.34.1
Loaded 100 of 2650 files, more files were not shown because too many files have changed in this diff. Show more