Re: [PATCH] Makefile: use -z pack-relative-relocs

From: Fangrui Song
Date: Fri Mar 24 2023 - 03:32:16 EST


On Thu, Mar 23, 2023 at 11:51 PM kernel test robot <lkp@xxxxxxxxx> wrote:
>
> Hi Fangrui,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on masahiroy-kbuild/for-next]
> [also build test WARNING on masahiroy-kbuild/fixes linus/master v6.3-rc3 next-20230323]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Fangrui-Song/Makefile-use-z-pack-relative-relocs/20230324-044515
> base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
> patch link: https://lore.kernel.org/r/20230323204427.3594372-1-maskray%40google.com
> patch subject: [PATCH] Makefile: use -z pack-relative-relocs
> config: arm64-randconfig-r022-20230322 (https://download.01.org/0day-ci/archive/20230324/202303241443.0sSziFDY-lkp@xxxxxxxxx/config)
> compiler: aarch64-linux-gcc (GCC) 12.1.0
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://github.com/intel-lab-lkp/linux/commit/8f47a36faf182f96a2bbf4d3b9305fe9a90c5cde
> git remote add linux-review https://github.com/intel-lab-lkp/linux
> git fetch --no-tags linux-review Fangrui-Song/Makefile-use-z-pack-relative-relocs/20230324-044515
> git checkout 8f47a36faf182f96a2bbf4d3b9305fe9a90c5cde
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 olddefconfig
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Link: https://lore.kernel.org/oe-kbuild-all/202303241443.0sSziFDY-lkp@xxxxxxxxx/
>
> All warnings (new ones prefixed by >>):
>
> >> aarch64-linux-ld: warning: -z pack-relative-relocs ignored
> >> aarch64-linux-ld: warning: -z pack-relative-relocs ignored
> >> aarch64-linux-ld: warning: -z pack-relative-relocs ignored
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests

I forgot to check aarch64-linux-gnu-ld. To address the issue I can use:

# ld.lld before 15 did not support -z pack-relative-relocs.
if ! $LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr -o
$tmp_file 2>/dev/null; then
$LD $tmp_file.o -shared -Bsymbolic -z pack-relative-relocs -o
$tmp_file 2>&1 |
grep -q pack-relative-relocs && exit 1
fi



--
宋方睿