|
1 | 1 | /**************************** elf2mac.cpp ********************************* |
2 | 2 | * Author: Agner Fog |
3 | 3 | * Date created: 2007-01-10 |
4 | | -* Last modified: 2012-05-05 |
| 4 | +* Last modified: 2025-10-30 |
5 | 5 | * Project: objconv |
6 | 6 | * Module: elf2mac.cpp |
7 | 7 | * Description: |
8 | 8 | * Module for converting ELF file to Mach-O file |
9 | 9 | * |
10 | | -* Copyright 2007-2012 GNU General Public License http://www.gnu.org/licenses |
| 10 | +* Copyright 2007-2025 GNU General Public License http://www.gnu.org/licenses |
11 | 11 | *****************************************************************************/ |
12 | 12 |
|
13 | 13 | #include "stdafx.h" |
@@ -224,7 +224,22 @@ void CELF2MAC<ELFSTRUCTURES,MACSTRUCTURES>::MakeSymbolTable() { |
224 | 224 |
|
225 | 225 | if (NewSymTab[0].GetNumEntries() == 0) { |
226 | 226 | // make empty symbol record for index 0 |
| 227 | + // NOTE on linking an objconv-elf2mac-converted .o with ld_classic vs. with ld_new: |
| 228 | + // - ld_classic can handle this dummy entry with n_type=MAC_N_UNDF(0) without any problem |
| 229 | + // - ld_new (indroduced with XCode 15) terminates with an assert, if it finds this dummy entry |
| 230 | + // with n_type=MAC_N_UNDF(0) and there are other non-dummy undefined symbol entries in the .o file: |
| 231 | + // 0 0x1045e81bc __assert_rtn + 72 |
| 232 | + // 1 0x10450d5bc ld::InputFiles::SliceParser::parseObjectFile(mach_o::Header const*) const + 15360 |
| 233 | + // 2 0x10451688c ld::InputFiles::SliceParser::parse() const + 696 |
| 234 | + // ... |
| 235 | + // ld: Assertion failed: (firstUndefinedSymbol != 0), function parseObjectFile, file InputFiles.cpp, line 1810. |
| 236 | + // - a working fix for objconv to make the ld_new happy: use MAC_N_ABS(2) for the n_type of the dummy entry! |
| 237 | +//#define ELF2MAC_USE_MAC_N_ABS_FOR_DUMMY_SYMBOL |
| 238 | +#ifndef ELF2MAC_USE_MAC_N_ABS_FOR_DUMMY_SYMBOL |
227 | 239 | NewSymTab[0].AddSymbol(0, "", 0, 0, 0, 0); |
| 240 | +#else |
| 241 | + NewSymTab[0].AddSymbol(0, "", MAC_N_ABS, 0, 0, 0); |
| 242 | +#endif |
228 | 243 | } |
229 | 244 |
|
230 | 245 | // Loop through old symbol table |
|
0 commit comments