@@ -54,8 +54,11 @@ const LE: Endianness = Endianness::Little;
5454/// offsets right after that (1GiB).
5555pub ( crate ) const MACHO_START_MEM_ADDRESS : u64 = 0x1_0000_0000 ;
5656
57+ /// The command alignment is 8B for 64-bit platforms.
58+ pub ( crate ) const MACHO_COMMAND_ALIGNMENT : usize = 8 ;
59+
5760/// A path to the default dynamic linker.
58- pub ( crate ) const DYLINKER_PATH : & str = "/usr/lib/dyld" ;
61+ pub ( crate ) const DYLINKER_PATH : & [ u8 ] = b "/usr/lib/dyld";
5962pub ( crate ) const DEFAULT_SEGMENT_COUNT : usize = 4 ;
6063pub ( crate ) const CHAINED_FIXUP_TABLE_SIZE : u64 =
6164 ( size_of :: < ChainedFixupsHeader > ( ) + size_of :: < u32 > ( ) * ( DEFAULT_SEGMENT_COUNT + 1 + 1 ) ) as u64 ;
@@ -729,9 +732,7 @@ impl platform::ProgramSegmentDef for ProgramSegmentDef {
729732 | output_section_id:: DYLD_CHAINED_FIXUPS => SegmentType :: LoadCommands ,
730733 output_section_id:: TEXT | output_section_id:: CSTRING => SegmentType :: TextSections ,
731734 output_section_id:: DATA => SegmentType :: DataSections ,
732- output_section_id:: CHAINED_FIXUP_TABLE | output_section_id:: STRTAB => {
733- SegmentType :: LinkeditSections
734- }
735+ output_section_id:: CHAINED_FIXUP_TABLE => SegmentType :: LinkeditSections ,
735736 _ => SegmentType :: Unused ,
736737 } ;
737738
@@ -1167,7 +1168,8 @@ impl platform::Platform for MachO {
11671168 sizes. increment ( part_id:: ENTRY_POINT , size_of :: < EntryPointCommand > ( ) as u64 ) ;
11681169 sizes. increment (
11691170 part_id:: INTERP ,
1170- ( ( size_of :: < DylinkerCommand > ( ) + DYLINKER_PATH . len ( ) ) . next_multiple_of ( 8 ) ) as u64 ,
1171+ ( ( size_of :: < DylinkerCommand > ( ) + DYLINKER_PATH . len ( ) )
1172+ . next_multiple_of ( MACHO_COMMAND_ALIGNMENT ) ) as u64 ,
11711173 ) ;
11721174 sizes. increment (
11731175 part_id:: DYLD_CHAINED_FIXUPS ,
@@ -1228,12 +1230,6 @@ impl platform::Platform for MachO {
12281230 symbol_db : & crate :: symbol_db:: SymbolDb < Self > ,
12291231 ) {
12301232 common. allocate ( part_id:: CHAINED_FIXUP_TABLE , CHAINED_FIXUP_TABLE_SIZE ) ;
1231- // TODO: Just a filler for now that will ensure the __LINKEDIT takes 16KiB - find a better
1232- // solution.
1233- common. allocate (
1234- part_id:: STRTAB ,
1235- MACHO_PAGE_ALIGNMENT . value ( ) - CHAINED_FIXUP_TABLE_SIZE ,
1236- ) ;
12371233 }
12381234
12391235 fn finalise_prelude_layout < ' data > (
@@ -1292,7 +1288,6 @@ impl platform::Platform for MachO {
12921288 builder. add_section ( output_section_id:: CSTRING ) ;
12931289 builder. add_section ( output_section_id:: DATA ) ;
12941290 // The rest (e.g. symbol table, string table).
1295- builder. add_section ( output_section_id:: STRTAB ) ;
12961291 builder. add_section ( output_section_id:: CHAINED_FIXUP_TABLE ) ;
12971292
12981293 builder. build ( )
@@ -1381,11 +1376,6 @@ const SECTION_DEFINITIONS: [BuiltInSectionDetails; NUM_BUILT_IN_SECTIONS] = {
13811376 target_segment_type : Some ( SegmentType :: LinkeditSections ) ,
13821377 ..DEFAULT_DEFS
13831378 } ;
1384- defs[ output_section_id:: STRTAB . as_usize ( ) ] = BuiltInSectionDetails {
1385- kind : SectionKind :: Primary ( SectionName ( b"STRING_TABLE" ) ) ,
1386- target_segment_type : Some ( SegmentType :: LinkeditSections ) ,
1387- ..DEFAULT_DEFS
1388- } ;
13891379 // Multi-part generated sections
13901380 defs[ output_section_id:: SYMTAB_GLOBAL . as_usize ( ) ] = BuiltInSectionDetails {
13911381 kind : SectionKind :: Secondary ( output_section_id:: SYMTAB_LOCAL ) ,
0 commit comments