ld: Assertion failed: (resultIndex < sectData.atoms.size())

Hi, I wanted to compile a project (For the compilation I used gcc-13 from home-brew) and I got the following error from the linker:

0  0x100e0f648  __assert_rtn + 72
1  0x100d43fac  ld::AtomPlacement::findAtom(unsigned char, unsigned long long, ld::AtomPlacement::AtomLoc const*&, long long&) const + 1204
2  0x100d59924  ld::InputFiles::SliceParser::parseObjectFile(mach_o::Header const*) const + 15164
3  0x100d66e30  ld::InputFiles::parseAllFiles(void (ld::AtomFile const*) block_pointer)::$_7::operator()(unsigned long, ld::FileInfo const&) const + 420
4  0x1a95f0440  _dispatch_client_callout2 + 20
5  0x1a9603f1c  _dispatch_apply_invoke + 224
6  0x1a95f0400  _dispatch_client_callout + 20
7  0x1a9601fb8  _dispatch_root_queue_drain + 684
8  0x1a96026c0  _dispatch_worker_thread2 + 164
9  0x1a979c038  _pthread_wqthread + 228
ld: Assertion failed: (resultIndex < sectData.atoms.size()), function findAtom, file Relocations.cpp, line 1336.
collect2: error: ld returned 1 exit status

I am using a MacBook Pro M2 (Ventura 13.5.2 (22G91)) and the CommandLineTools version 15.0. I have read through some earlier posts about linker issues, which were solved by downgrading Xcode. After downgrading to 14.3.0 I was able to compile the code. Did anyone run into the same Problem? If so, is there a better solution for this?

Best regards

Answered by DTS Engineer in 765203022

Xcode 15, and its associated Command Line Tools package, includes a new linker implementation. See here.

I recommend that you temporarily switch to the old linker implementation. I suspect that’ll avoid this crash.

If it does, please file a bug about this. My experience is that problems like this are usually caused by third-party tools generating incorrect Mach-O object files but:

  • The linker team needs to look at this, just to be sure.

  • Even if it is, the linker probably shouldn’t crash (-:

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Same failure under OSX 14 but command line tools 14.3 won't install on OSX 14.

Fixed by adding to gpr file: package Linker is for Default_Switches ("ada") use ("-Wl,-ld_classic"); end case;

My program now links and executes under OSX 14 Sobono and CLT15.

For command line use: -largs -Wl,-ld_classic

I could not downgrade Command Line Tools 4.3.1 as installer refused with error "operating system is too new", so I installed 5.1.0 beta3 and it worked.

I think the issue was fixed somewhere with 5.1.0 beta1 or so.

This is solved for me with the update of Xcode Command Line tools to version 15.0.1 (15A507)

However, 15.0.1 has not yet, but Xcode 15.1.0 (22502) has solved this issue for me.

Xcode 15.1.0 (22502) has solved this issue for me.

Cool. That aligns with the resolution of state for FB13192247.

Thanks for confirming!

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I still have the issue on XCode 15.2, how's this possible? (cry)

how's this possible?

What was your bug number?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

-isysroot flag helped me get rid of the bug

ld: Assertion failed: (resultIndex &lt; sectData.atoms.size())
 
 
Q