Project

General

Profile

Actions

Bug #15028

open

gld-2.39: warning: ... has a LOAD segment with RWX permissions

Added by Marcel Telka 2 months ago. Updated about 2 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
tools - gate/build tools
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

When tried to build illumos-gate with binutils 2.39 the nightly produce this noise:

/usr/bin/gld: warning: pre_stage2.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: diskless.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: e2fs_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: fat_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: ffs_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: iso9660_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: jfs_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: minix_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: nbloader.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: pxeloader.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: reiserfs_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: start.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: start_eltorito.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: ufs2_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: ufs_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: zfs_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: vstafs_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: xfs_stage1_5.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: stage1.exec has a LOAD segment with RWX permissions
/usr/bin/gld: warning: gptldr.out has a LOAD segment with RWX permissions
/usr/bin/gld: warning: isoboot.out has a LOAD segment with RWX permissions
/usr/bin/gld: warning: gptldr.out has a LOAD segment with RWX permissions
/usr/bin/gld: warning: gptzfsboot.out has a LOAD segment with RWX permissions
/usr/bin/gld: warning: loader.sym has a LOAD segment with RWX permissions

It looks like the gld produces the same result as before where the LOAD section is and always was rwx (checked with both 2.38 and 2.39):

$ elfdump usr/src/grub/grub-0.97/stage2/pre_stage2.exec | ggrep -C2 PT_LOAD
Program Header[0]:
    p_vaddr:      0x8200      p_flags:    [ PF_X PF_W PF_R ]
    p_paddr:      0x8200      p_type:     [ PT_LOAD ]
    p_filesz:     0x21cb8     p_memsz:    0x593a4
    p_offset:     0x60        p_align:    0x20
$

The only difference is that 2.39 started to warn about that. There is new gld option --no-warn-rwx-segments (introduced in 2.39) that suppresses the warning, but it is not available in 2.38 or older.

Actions #1

Updated by Marcel Telka 2 months ago

  • Description updated (diff)
Actions #2

Updated by Marcel Telka 2 months ago

  • Description updated (diff)
Actions #3

Updated by Marcel Telka 2 months ago

Here is a workaround for both grub and loader implemented in OpenIndiana to be able to build illumos-gate with binutils 2.39:

https://github.com/OpenIndiana/oi-userland/commit/44a04e21aa4e7caa77ad62d78fdcd3735b2a92dd

Actions #4

Updated by Andy Fiddaman 2 months ago

The workaround that OmniOS used was to build binutils without this check since it seems that 32-bit program header data segments are indeed RWX on illumos. If this is intentional then binutils should be fixed to skip the warning on illumos.

https://github.com/omniosorg/omnios-build/blob/master/build/binutils/build.sh#L51

Actions #5

Updated by Rich Lowe 2 months ago

They're RWX by default on illumos for compat (i386) and ABI (the SPARC PLT is read/write) reasons, but we have mapfile.noexdata which everyone should use to make them not be where they can not be.

For gld, you're talking about loader and grub, whether they should or should not be is a matter of what they expect and what they do, I don't know the answer.

Whether patching it out makes sense depends on what gld is doing by default. If it's defaulting to RWX as we do, then complaining about it, that seems silly.

If our booters can be told to stop doing this, that seems generally better (if they even really program page protections at all).

Actions #6

Updated by Marcel Telka about 2 months ago

Me: Where is the linker script that would need to be updated to fix the problem properly?
Toomas: loader has one boot/i386/boot.ldscript, but that one is specific for boot2 bits (gptzfsboot, isoboot), bios loader itself has it in loader directory (ldscript.i386). I haven't checked grub (my motivation to touch grub is very low;)

Actions

Also available in: Atom PDF