Project

General

Profile

Actions

Bug #20677

closed

error: mach-o section specifier requires a segment whose length is between 1 and 16 characters

Added by ryandesign (Ryan Carsten Schmidt) 3 months ago. Updated 3 months ago.


Description

ruby (the development version as of 2024-08-11) does not build on macOS 11 or earlier with Apple Clang 1300 or earlier:

coroutine/amd64/Context.S:74:14: error: mach-o section specifier requires a segment whose length is between 1 and 16 characters
.pushsection .note.gnu.property, "a"
             ^
coroutine/amd64/Context.S:86:12: error: .popsection without corresponding .pushsection
.popsection
           ^
make: *** [coroutine/amd64/Context.o] Error 1

Here is the bug I filed with MacPorts about this: https://trac.macports.org/ticket/70537

It does build on newer systems with Apple Clang 1316 or later and on older systems when using a newer llvm.org clang compiler but it would be better if a newer compiler were not required.


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #18061: Execshield test: libruby.so.N.N.N: FAIL: property-note test because no .note.gnu.property section foundClosedkjtsanaktsidis (KJ Tsanaktsidis)Actions
Actions #1

Updated by mame (Yusuke Endoh) 3 months ago

  • Related to Bug #18061: Execshield test: libruby.so.N.N.N: FAIL: property-note test because no .note.gnu.property section found added
Actions #2

Updated by mame (Yusuke Endoh) 3 months ago

  • Assignee set to kjtsanaktsidis (KJ Tsanaktsidis)

@kjtsanaktsidis (KJ Tsanaktsidis) Could you take a look?

Updated by kjtsanaktsidis (KJ Tsanaktsidis) 3 months ago

Ah. I might have to add some feature detection to the configure script for this when deciding if BTI/PAC is available.

Can you tell me, does it work if you compile with ASFLAGS=-fno-integrated-as?

Updated by kjtsanaktsidis (KJ Tsanaktsidis) 3 months ago

deciding if BTI/PAC is available.

Silly me, this is about amd64.

So what you're running into is that I added a .note.gnu.property to the amd64 one in https://github.com/ruby/ruby/commit/8ec67052e67dff62b828820e381a94a3acc73459 and it's unconditional in whether the CET macro is defined or not. The arm64 property only gets emitted if BTI/PAC-RET is enabled.

I actually don't understand how this works at all even on modern macOS; AFAICT the max section size is still 16 chars (https://github.com/llvm/llvm-project/blob/82fdfd4aa7f60b1f8e715211b925a7f2bfe57ea9/llvm/lib/MC/MCSectionMachO.cpp#L208-L211). Looking into it some more...

Updated by kjtsanaktsidis (KJ Tsanaktsidis) 3 months ago

https://github.com/ruby/ruby/pull/11405 - I think this should fix it. It seems new toolchains truncate the section name, rather than throwing that error about "length is between 1 and 16 characters", but in any case the section is meaningless on MacOS so it's best to just not emit it.

Actions #6

Updated by kjtsanaktsidis (KJ Tsanaktsidis) 3 months ago

  • Status changed from Open to Closed

Applied in changeset git|86c2724e75375ceb165c378ed4261c551136e593.


Don't emit ELF notes on non-ELF platforms

These apparently break compilation on old MacOS toolchains, because the
MachO section name is capped to 16 chars (although, on my MacOS, at
least, the section name just gets truncated). Nevertheless, these serve
no purpose on non-ELF platforms (they're part of the LSB Linux ABI).

[Bug #20677]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0