Changeset 068dd86 in mainline


Ignore:
Timestamp:
2023-08-04T13:07:34Z (10 months ago)
Author:
Vojtech Horky <vojtech.horky@…>
Branches:
ticket/834-toolchain-update
Children:
24cf6694
Parents:
4dbcdf3
Message:

Support linker without —no-warn-rwx-segments

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/meson.build

    r4dbcdf3 r068dd86  
    8787kernel_link_args = arch_kernel_link_args + [
    8888        '-Wl,--nmagic',
    89         # The kernel is built as ELF but then copied as a blob of bytes and
    90         # the permissions are not relevant anyway (needed for binutils 2.39+).
    91         '-Wl,--no-warn-rwx-segments',
    9289        '-T', meson.current_build_dir() / '_link.ld',
    9390]
     91# The kernel is built as ELF but then copied as a blob of bytes and
     92# the permissions are not relevant anyway (needed for binutils 2.39+).
     93kernel_link_args += ldflags_ignore_rwx_segments
    9494
    9595if CONFIG_LTO
     
    104104kernel_c_args = arch_kernel_c_args + kernel_defs + [
    105105        '-ffreestanding',
    106         # When accessing specific memory addresses that are below normal page size,
    107         # the compiler may assume that we actually dereferenced NULL pointer and
    108         # warns us about that. But in kernel we often need to access these
    109         # addresses directly hence we need to ignore these warnings.
    110         #
    111         # TODO: might make more sense to disable this selectively in specific
    112         # files (or better yet, for specific lines).
    113         '--param=min-pagesize=0',
    114         # TODO: remove this flag
    115         cc.get_supported_arguments([ '-Wno-cast-function-type' ]),
     106        cc.get_supported_arguments([
     107                # TODO: remove this flag
     108                '-Wno-cast-function-type',
     109                # When accessing specific memory addresses that are below normal page
     110                # size, the compiler may assume that we actually dereferenced NULL
     111                # pointer and warns us about that. But in kernel we often need to
     112                # access these addresses directly hence we need to ignore these
     113                # warnings.
     114                #
     115                # TODO: might make more sense to disable this selectively in specific
     116                # files (or better yet, for specific lines).
     117                '--param=min-pagesize=0',
     118        ]),
    116119]
    117120
  • meson/arch/arm64/meson.build

    r4dbcdf3 r068dd86  
    4444# -mstrict-align option is therefore not needed.
    4545arch_boot_c_args = arch_uspace_c_args + [ '-fpic', '-fvisibility=hidden', '-fno-function-sections' ]
    46 arch_boot_link_args = [ '-Wl,-shared', '-Wl,--no-gc-sections' ]
    47 arch_boot_link_args += ['-Wl,--no-warn-rwx-segments']
     46arch_boot_link_args = [ '-Wl,-shared', '-Wl,--no-gc-sections' ] + ldflags_ignore_rwx_segments
    4847
    4948if MACHINE == 'virt'
  • meson/arch/ia64/meson.build

    r4dbcdf3 r068dd86  
    3838arch_uspace_link_args = [ '-nostdlib', '-lgcc' ]
    3939arch_kernel_link_args = [ '-nostdlib', '-Wl,-EL' ]
    40 arch_boot_link_args = ['-Wl,--no-warn-rwx-segments']
     40arch_boot_link_args = ldflags_ignore_rwx_segments
    4141
    4242
  • meson/arch/ppc32/meson.build

    r4dbcdf3 r068dd86  
    3737arch_kernel_link_args = [ '-nostdlib', '-Wl,-z,max-page-size=0x1000', '-Wl,--no-check-sections', '-Wl,--no-gc-sections' ]
    3838arch_uspace_link_args = [ '-nostdlib', '-lgcc', '-Wl,-z,max-page-size=0x1000' ]
    39 arch_uspace_link_args += ['-Wl,--no-warn-rwx-segments']
    40 arch_boot_link_args = ['-Wl,--no-warn-rwx-segments']
     39arch_uspace_link_args += ldflags_ignore_rwx_segments
     40arch_boot_link_args = ldflags_ignore_rwx_segments
    4141
    4242
  • meson/arch/riscv64/meson.build

    r4dbcdf3 r068dd86  
    3333arch_kernel_link_args = [ '-nostdlib' ]
    3434arch_uspace_link_args = [ '-nostdlib', '-lgcc' ]
    35 arch_boot_link_args = ['-Wl,--no-warn-rwx-segments']
     35arch_boot_link_args = ldflags_ignore_rwx_segments
    3636
    3737rd_essential += [
  • meson/part/compiler_args/meson.build

    r4dbcdf3 r068dd86  
    129129        add_project_link_arguments(extra_cflags, language : [ lang ])
    130130endforeach
     131
     132# This flag is needed at several places, hence we define it here.
     133#
     134# For backwards compatibility we try to detect --no-warn-rwx-segments.
     135# However, the autodetection done by Meson also results in
     136# "cannot find entry symbol _start; defaulting to 00000000004000b0"
     137# thus the option is never supported alone. So when detecting we also
     138# specify --entry=main so that the stub source provided by Meson is build
     139# correctly.
     140ldflags_ignore_rwx_segments = []
     141if cc.has_link_argument('-Wl,--no-warn-rwx-segments,--entry=main')
     142    ldflags_ignore_rwx_segments += ['-Wl,--no-warn-rwx-segments']
     143endif
Note: See TracChangeset for help on using the changeset viewer.