├── APPLE_LICENSE ├── README.md ├── compile_stubs ├── doc ├── design │ ├── bindings.png │ ├── hello.png │ └── linker.html └── man │ └── man1 │ ├── ld-classic.1 │ ├── ld64.1 │ └── unwinddump.1 ├── ld64.xcodeproj └── project.pbxproj ├── src ├── abstraction │ ├── Containers.h │ ├── FileAbstraction.hpp │ ├── MachOFileAbstraction.hpp │ └── MachOTrie.hpp ├── create_configure ├── ld │ ├── Architectures.hpp │ ├── Bitcode.hpp │ ├── FatFile.cpp │ ├── FatFile.h │ ├── HeaderAndLoadCommands.hpp │ ├── InputFiles.cpp │ ├── InputFiles.h │ ├── LinkEdit.hpp │ ├── LinkEditClassic.hpp │ ├── Mangling.cpp │ ├── Mangling.h │ ├── Options.cpp │ ├── Options.h │ ├── OutputFile.cpp │ ├── OutputFile.h │ ├── PlatformSupport.cpp │ ├── PlatformSupport.h │ ├── Resolver.cpp │ ├── Resolver.h │ ├── ResponseFiles.cpp │ ├── ResponseFiles.h │ ├── Snapshot.cpp │ ├── Snapshot.h │ ├── SymbolTable.cpp │ ├── SymbolTable.h │ ├── code-sign-blobs │ │ ├── blob.cpp │ │ ├── blob.h │ │ ├── endian.h │ │ ├── memutils.h │ │ └── superblob.h │ ├── cs_blobs.h │ ├── debugline.c │ ├── debugline.h │ ├── dwarf2.h │ ├── ld.cpp │ ├── ld.hpp │ ├── libcodedirectory.c │ ├── libcodedirectory.h │ ├── parsers │ │ ├── archive_file.cpp │ │ ├── archive_file.h │ │ ├── generic_dylib_file.cpp │ │ ├── generic_dylib_file.hpp │ │ ├── libunwind │ │ │ ├── AddressSpace.hpp │ │ │ ├── DwarfInstructions.hpp │ │ │ ├── DwarfParser.hpp │ │ │ ├── InternalMacros.h │ │ │ └── Registers.hpp │ │ ├── lto_file.cpp │ │ ├── lto_file.h │ │ ├── macho_dylib_file.cpp │ │ ├── macho_dylib_file.h │ │ ├── macho_relocatable_file.cpp │ │ ├── macho_relocatable_file.h │ │ ├── opaque_section_file.cpp │ │ ├── opaque_section_file.h │ │ ├── textstub_dylib_file.cpp │ │ └── textstub_dylib_file.hpp │ └── passes │ │ ├── bitcode_bundle.cpp │ │ ├── bitcode_bundle.h │ │ ├── branch_island.cpp │ │ ├── branch_island.h │ │ ├── branch_shim.cpp │ │ ├── branch_shim.h │ │ ├── code_dedup.cpp │ │ ├── code_dedup.h │ │ ├── compact_unwind.cpp │ │ ├── compact_unwind.h │ │ ├── dtrace_dof.cpp │ │ ├── dtrace_dof.h │ │ ├── dylibs.cpp │ │ ├── dylibs.h │ │ ├── got.cpp │ │ ├── got.h │ │ ├── huge.cpp │ │ ├── huge.h │ │ ├── inits.cpp │ │ ├── inits.h │ │ ├── objc.cpp │ │ ├── objc.h │ │ ├── objc_constants.cpp │ │ ├── objc_constants.h │ │ ├── objc_stubs.cpp │ │ ├── objc_stubs.h │ │ ├── order.cpp │ │ ├── order.h │ │ ├── stubs │ │ ├── make_stubs.h │ │ ├── stub_arm.hpp │ │ ├── stub_arm64.hpp │ │ ├── stub_arm64_32.hpp │ │ ├── stub_arm64e.hpp │ │ ├── stub_arm_classic.hpp │ │ ├── stub_x86.hpp │ │ ├── stub_x86_64.hpp │ │ ├── stub_x86_64_classic.hpp │ │ ├── stub_x86_classic.hpp │ │ └── stubs.cpp │ │ ├── thread_starts.cpp │ │ ├── thread_starts.h │ │ ├── tlvp.cpp │ │ └── tlvp.h ├── llvm │ ├── llvm-AlignOf.h │ ├── llvm-DenseMap.h │ ├── llvm-DenseMapInfo.h │ ├── llvm-DenseSet.h │ ├── llvm-MathExtras.h │ └── llvm-type_traits.h ├── mach_o │ ├── Error.cpp │ ├── Error.h │ ├── ExportsTrie.cpp │ └── ExportsTrie.h └── other │ ├── ObjectDump.cpp │ ├── PruneTrie.cpp │ ├── objcimageinfo.cpp │ ├── prune_trie.h │ └── unwinddump.cpp ├── unit-tests ├── README ├── bin │ ├── exit-non-zero-pass.pl │ ├── fail-if-exit-non-zero.pl │ ├── fail-if-exit-zero.pl │ ├── fail-if-no-stdin.pl │ ├── fail-if-stdin.pl │ ├── fail-iff-exit-zero.pl │ ├── make-recursive-newtest.pl │ ├── make-recursive.pl │ ├── mkld │ ├── pass-iff-exit-non-zero.pl │ ├── pass-iff-exit-zero.pl │ ├── pass-iff-no-stdin.pl │ ├── pass-iff-stdin.pl │ ├── result-filter.pl │ └── rm-stale-test-logs ├── clean-tests ├── include │ ├── common.makefile │ └── test.h ├── proctor-run ├── run-all-unit-tests ├── run-all-unit-tests-debug ├── src │ ├── Makefile │ ├── results-to-xml.cpp │ └── xmlparser │ │ ├── xmlparser.1 │ │ ├── xmlparser.m │ │ ├── xmlparser.xcodeproj │ │ └── project.pbxproj │ │ └── xmlparser_Prefix.pch └── test-cases │ ├── 16-byte-alignment │ ├── Makefile │ ├── comment.txt │ └── tl_test2.c │ ├── Lpath │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── absolute-symbol │ ├── Makefile │ ├── abs.s │ └── main.c │ ├── alias-basic │ ├── Makefile │ ├── aliases.s │ └── main.c │ ├── alias-command-line │ ├── Makefile │ ├── aliases.s │ └── aliases.txt │ ├── alias-objects │ ├── Makefile │ └── aliases.s │ ├── align-atom-in-page │ ├── Makefile │ ├── foo.s │ └── foo_align.s │ ├── align-modulus │ ├── Makefile │ ├── align.s │ ├── comment.txt │ ├── foo.c │ └── foo.exp │ ├── all-load-file-sources │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── filelist │ ├── foo.c │ └── main.c │ ├── allow-stack-execute │ ├── Makefile │ ├── comment.txt │ └── foo.c │ ├── allow_heap_execute │ ├── Makefile │ └── main.c │ ├── allowable-client │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── comment.txt │ ├── foo.c │ └── main.c │ ├── alt-entry │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── archive-ObjC-unexported │ ├── Makefile │ ├── bar.m │ ├── foo.m │ ├── main.m │ └── main.nexp │ ├── archive-ObjC │ ├── Makefile │ ├── bar.c │ ├── baz.m │ ├── foo.m │ └── main.c │ ├── archive-basic │ ├── Makefile │ ├── bar.c │ ├── comment.txt │ ├── foo.c │ └── main.c │ ├── archive-duplicate │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── archive-force-load │ ├── Makefile │ ├── bar.c │ ├── bat.c │ ├── baz.c │ ├── foo.c │ └── main.c │ ├── archive-image_info │ ├── Makefile │ └── main.m │ ├── archive-init-order │ ├── Makefile │ ├── bar.c │ ├── bar2.c │ ├── bar3.c │ ├── foo.c │ ├── foo2.c │ ├── foo3.c │ └── main.c │ ├── archive-order │ ├── Makefile │ ├── bar.c │ ├── bar2.c │ ├── bar3.c │ ├── expected.order │ ├── foo.c │ ├── foo2.c │ ├── foo3.c │ └── main.c │ ├── archive-r-ObjC │ ├── Makefile │ ├── bar.c │ ├── baz.m │ ├── cat.m │ ├── foo.m │ └── main.c │ ├── archive-weak │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── comment.txt │ ├── foo.c │ └── main.c │ ├── auto-arch │ ├── Makefile │ └── hello.c │ ├── bind_at_load │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── blank-stubs │ ├── Makefile │ ├── comment.txt │ ├── foo.c │ └── main.c │ ├── branch-distance │ ├── Makefile │ ├── bar.s │ └── foo.s │ ├── branch-interworking │ ├── Makefile │ ├── myarm.s │ └── mythumb.s │ ├── branch-islands │ ├── Makefile │ ├── atomic_space.s │ ├── extra.c │ ├── hello.c │ └── space.s │ ├── branch-long │ ├── Makefile │ ├── bar.s │ └── foo.c │ ├── bundle_loader │ ├── Makefile │ ├── bar.c │ ├── bundle.c │ └── main.c │ ├── cfstring-and-cstring │ ├── Makefile │ ├── bar.c │ └── foo.c │ ├── cfstring-coalesce │ ├── Makefile │ ├── bar.c │ └── foo.c │ ├── cfstring-utf16 │ ├── Makefile │ ├── bar.m │ └── foo.m │ ├── check-init-abs │ ├── .mod_init_func │ ├── Makefile │ ├── init.s │ ├── main.c │ └── term.s │ ├── check-init-bind │ ├── .mod_init_func │ ├── Makefile │ ├── init.s │ ├── main.c │ └── term.s │ ├── check-init-no-rebase │ ├── .mod_init_func │ ├── Makefile │ ├── init.s │ ├── main.c │ └── term.s │ ├── coalesce-force │ ├── Makefile │ ├── foo.c │ └── foo.exp │ ├── coalesce_weak_def_in_dylib │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── code-dedup-order │ ├── Makefile │ ├── bar.cpp │ ├── bar.h │ ├── baz.cpp │ └── foo.cpp │ ├── code-signed-object-file │ ├── Makefile │ └── foo.c │ ├── commons-alignment │ ├── Makefile │ └── foo.s │ ├── commons-coalesced-dead_strip │ ├── Makefile │ ├── a.c │ ├── b.c │ ├── c.c │ └── c.h │ ├── commons-mixed │ ├── Makefile │ ├── bar.c │ └── foo.c │ ├── commons-only-concrete-overrides │ ├── Makefile │ ├── libfoo.c │ ├── libfoo_tent.c │ ├── main.c │ └── main_extern.c │ ├── commons-order │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── expected.order │ ├── foo.c │ └── main.c │ ├── commons-private-extern-overrides │ ├── Makefile │ ├── libfoo.c │ └── main.c │ ├── compact-unwind-basic │ ├── Makefile │ └── test.s │ ├── cpu-sub-types-preference │ ├── Makefile │ └── foo.c │ ├── cpu-sub-types │ ├── Makefile │ ├── comment.txt │ ├── foo.c │ └── main.c │ ├── cstring-alt-segment │ ├── Makefile │ ├── custom.s │ └── main.c │ ├── cstring-custom-section │ ├── Makefile │ ├── bar.s │ └── foo.s │ ├── cstring-empty-labeled │ ├── Makefile │ └── foo.s │ ├── cstring-labels │ ├── Makefile │ ├── bar.c │ └── foo.c │ ├── custom-segment-layout │ ├── Makefile │ ├── main.c │ └── zero.s │ ├── data-in-code │ ├── Makefile │ └── test.s │ ├── dead_strip-archive-duplicate-def │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── dead_strip-archive-eh │ ├── Makefile │ ├── bar.cxx │ ├── foo.cxx │ └── main.cxx │ ├── dead_strip-archive-global │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── dead_strip-archive-weak-override │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── dead_strip-archive-weak │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── dead_strip-archive │ ├── Makefile │ ├── comment.txt │ ├── foo.c │ └── main.c │ ├── dead_strip-coalesced-order │ ├── Makefile │ ├── foo.cpp │ └── main.cpp │ ├── dead_strip-entry-archive │ ├── Makefile │ ├── bar.c │ └── foo.c │ ├── dead_strip-init-archive │ ├── Makefile │ ├── bar.c │ └── foo.c │ ├── dead_strip-initializers │ ├── Makefile │ ├── main.cxx │ └── other.cxx │ ├── dead_strip-live-if-ref-live │ ├── Makefile │ └── main.c │ ├── dead_strip-r_symbol_desc │ ├── Makefile │ └── main.c │ ├── dead_strip-weak-coalesce │ ├── Makefile │ ├── baz.c │ ├── foo.c │ └── main.c │ ├── dead_strip │ ├── Makefile │ ├── comment.txt │ ├── deadwood.c │ ├── main.c │ └── main.exp │ ├── dead_strip_dylibs │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── foo.c │ └── main.c │ ├── dead_strip_section_attribute │ ├── Makefile │ ├── comment.txt │ └── main.c │ ├── dead_strippable_dylib │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── foo.c │ └── main.c │ ├── demangle │ ├── Makefile │ └── main.cxx │ ├── dependency-logging │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── dirty-data-alt-entry │ ├── 1.dirty │ ├── 2.dirty │ ├── Makefile │ └── test.s │ ├── dso_handle │ ├── Makefile │ └── test.c │ ├── dtrace-old-probes │ ├── Makefile │ └── main.c │ ├── dtrace-static-probes-coalescing │ ├── Makefile │ ├── Number.d │ ├── a.cxx │ ├── header.h │ └── x.cxx │ ├── dtrace-static-probes │ ├── Makefile │ ├── bar.d │ ├── comment.txt │ ├── foo.d │ └── main.c │ ├── duplicate_symbols │ ├── Makefile │ ├── duplicates.c │ ├── main_extern.c │ └── main_no_extern.c │ ├── dwarf-archive-all_load │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── comment.txt │ ├── expected-stabs │ ├── foo.c │ └── stabs-filter.pl │ ├── dwarf-debug-notes-lto │ ├── Makefile │ ├── header.h │ ├── hello.cxx │ └── other.cxx │ ├── dwarf-debug-notes-missing-directory │ ├── Makefile │ └── foo.c │ ├── dwarf-debug-notes-r │ ├── Makefile │ ├── bar.cxx │ ├── comment.txt │ ├── expected-stabs │ ├── foo.cxx │ ├── main.cxx │ └── stabs-filter.pl │ ├── dwarf-debug-notes-uuid │ ├── Makefile │ └── main.c │ ├── dwarf-debug-notes │ ├── Makefile │ ├── comment.txt │ ├── expected-stabs │ ├── header.h │ ├── hello.cxx │ ├── hello.order │ ├── other.cxx │ └── stabs-filter.pl │ ├── dwarf-ignore │ ├── Makefile │ ├── comment.txt │ └── hello.c │ ├── dwarf-strip-objc │ ├── Makefile │ └── hello.m │ ├── dwarf-strip │ ├── Makefile │ ├── comment.txt │ └── hello.c │ ├── dyld-fixup-chains │ ├── Makefile │ └── main.c │ ├── dylib-aliases │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── dylib-main │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── dylib-re-export-cycle │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── dylib-upward │ ├── Makefile │ ├── bar.c │ └── foo.c │ ├── dylib_file-missing │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── dylib_file │ ├── Makefile │ ├── bar.c │ ├── comment.txt │ ├── foo.c │ └── main.c │ ├── dylib_init │ ├── Makefile │ └── foo.c │ ├── efi-basic │ ├── LibTest.c │ ├── Makefile │ ├── MtocTest.c │ ├── efi-pecoff-util │ └── mtoctest.py │ ├── eh-coalescing-no-labels │ ├── Makefile │ ├── bar.c │ ├── baz.c │ └── foo.c │ ├── eh-coalescing-r │ ├── Makefile │ ├── bar.cxx │ ├── baz.cxx │ ├── foo.cxx │ └── func.h │ ├── eh-coalescing │ ├── Makefile │ ├── bar.cxx │ ├── foo.cxx │ ├── foo2.cxx │ └── func.h │ ├── eh-strip-test │ ├── Makefile │ ├── comment.txt │ └── main.cxx │ ├── eh-stripped-symbols │ ├── Makefile │ ├── keep.exp │ └── main.cxx │ ├── eh_frame │ ├── Makefile │ ├── bar.cxx │ └── foo.cxx │ ├── empty-dylib │ ├── Makefile │ ├── empty.c │ └── justdata.c │ ├── empty-object │ ├── Makefile │ └── main.c │ ├── end-label │ ├── Makefile │ ├── bar.s │ └── foo.s │ ├── exported-symbols-dead_strip │ ├── Makefile │ ├── foo.c │ └── foo.exp │ ├── exported-symbols-wildcards-dead_strip │ ├── Makefile │ └── foo.c │ ├── exported-symbols-wildcards │ ├── Makefile │ ├── expect1 │ ├── expect2 │ ├── expect3 │ ├── expect4 │ ├── expect5 │ ├── expect6 │ ├── expect7 │ ├── expect8 │ ├── foo.c │ └── list5 │ ├── exported_symbols_list-eol │ ├── Makefile │ ├── expected.nm │ ├── test.c │ └── test.exp │ ├── exported_symbols_list-hidden │ ├── Makefile │ ├── test.c │ └── test.exp │ ├── exported_symbols_list-r │ ├── Makefile │ ├── test-bad.exp │ ├── test.c │ └── test.exp │ ├── external-reloc-sorting │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── fatal_warning │ ├── Makefile │ └── main.c │ ├── filelist │ ├── Makefile │ ├── comment.txt │ └── hello.c │ ├── fixup-chains-page-overlap │ ├── Makefile │ ├── main.c │ ├── page_overlap.s │ └── page_overlap_align.s │ ├── flat-dylib │ ├── Makefile │ └── main.c │ ├── flat-indirect-undefines │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── flat-main │ ├── Makefile │ └── main.c │ ├── force-weak │ ├── Makefile │ ├── foo.c │ ├── test.c │ └── weak.exp │ ├── function-starts │ ├── Makefile │ └── main.c │ ├── got-elimination │ ├── Makefile │ ├── bar.c │ └── foo.c │ ├── header-pad │ ├── Makefile │ ├── comment.txt │ └── hello.c │ ├── hello-world │ ├── Makefile │ ├── comment.txt │ └── hello.c │ ├── hidden-r │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── image_suffix │ ├── Makefile │ ├── bar.c │ └── foo.c │ ├── implicit-common2 │ ├── Makefile.newtest │ ├── a.c │ ├── comment.txt │ └── test.c │ ├── implicit-common4 │ ├── Makefile.newtest │ ├── a.c │ ├── comment.txt │ └── test.c │ ├── implicit-common5 │ ├── Makefile.newtest │ ├── a.c │ ├── comment.txt │ └── test.c │ ├── implicit_dylib │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── indirect-dylib │ ├── Makefile │ ├── bar.c │ ├── comment.txt │ ├── foo.c │ └── main.c │ ├── indirect-path-search │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── foo.c │ └── main.c │ ├── init-order │ ├── Makefile │ ├── bar.cxx │ ├── expected-order.txt │ ├── foo.cxx │ └── main.cxx │ ├── install-name-override │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── interposable_list │ ├── Makefile │ ├── test.c │ └── test.exp │ ├── kext-basic │ ├── Makefile │ ├── mykext.c │ └── mykextinfo.c │ ├── kext-fixup-chains │ ├── Makefile │ └── main.c │ ├── kext-undefined-export │ ├── Makefile │ ├── mykext-i386.exp │ ├── mykext.c │ ├── mykext.exp │ └── mykextinfo.c │ ├── label-on-end-of-section-order │ ├── Makefile │ └── foo.s │ ├── label-on-end-of-section │ ├── Makefile │ └── foo.s │ ├── large-bss │ ├── Makefile │ └── test.s │ ├── large-data │ ├── Makefile │ ├── test1.c │ ├── test2.c │ ├── test3.c │ └── test4.c │ ├── late-link-error │ ├── Makefile │ ├── comment.txt │ └── link_error.s │ ├── lazy-dylib-objc │ ├── Makefile │ ├── foo.h │ ├── foo.m │ └── main.m │ ├── lazy-dylib │ ├── Makefile │ ├── bad.c │ ├── bad2.c │ ├── foo.c │ └── main.c │ ├── linker-optimization-hints │ ├── AdrpAdd.s │ ├── AdrpAddLdr.s │ ├── AdrpAddStr.s │ ├── AdrpLdr.s │ ├── AdrpLdrGot.s │ ├── AdrpLdrGotLdr.s │ ├── AdrpLdrGotLdrField.s │ ├── AdrpLdrGotStr.s │ ├── Makefile │ └── main.s │ ├── linker_options-framework-static-chain │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── foo.c │ └── main.c │ ├── linker_options-framework-static │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── linker_options-framework │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── linker_options-library-chain │ ├── Makefile │ ├── bar.c │ ├── foo.c │ ├── main.c │ └── subbar.c │ ├── linker_options-library │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── linker_options-needed-library │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── literals-coalesce-alignment │ ├── Makefile │ ├── cstring-align-0.s │ └── cstring-align-3.s │ ├── literals-coalesce-alignment2 │ ├── Makefile │ ├── comment.txt │ ├── cstring-align-0.s │ └── cstring-align-3.s │ ├── literals-coalesce-alignment3 │ ├── Makefile │ ├── comment.txt │ ├── cstring-align-0.s │ └── cstring-align-3.s │ ├── literals-coalesce │ ├── Makefile │ └── literals.s │ ├── literals-coalesce2 │ ├── Makefile.newtest │ ├── comment.txt │ ├── literals.s │ └── test.sh │ ├── literals-labels │ ├── Makefile │ └── literals.s │ ├── llvm-integration │ ├── Makefile │ ├── a.c │ ├── a1.c │ ├── a10.c │ ├── a11.c │ ├── a12.c │ ├── a12.h │ ├── a13.cc │ ├── a13.h │ ├── a14.c │ ├── a15.c │ ├── a17.c │ ├── a18.c │ ├── a2.c │ ├── a20.c │ ├── a3.c │ ├── a4.c │ ├── a5.c │ ├── a6.c │ ├── a7.c │ ├── a8.c │ ├── a9.c │ ├── a9.list │ ├── b.c │ ├── b1.c │ ├── b10.c │ ├── b10.h │ ├── b14.c │ ├── b15.c │ ├── b17.c │ ├── b2.c │ ├── b20.c │ ├── b3.c │ ├── b4.c │ ├── b5.c │ ├── b7.c │ ├── c15.c │ ├── main.c │ ├── main1.c │ ├── main10.c │ ├── main11.c │ ├── main12.c │ ├── main13.cc │ ├── main16.c │ ├── main19.c │ ├── main2.c │ ├── main20.c │ ├── main3.c │ ├── main4.c │ ├── main5.c │ ├── main6.c │ ├── main7.c │ ├── main8.c │ └── main9.c │ ├── loader_path │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── local-symbol-partial-stripping │ ├── Makefile │ ├── a.expect │ ├── a.list │ ├── b.expect │ ├── b.list │ ├── c.list │ ├── foo.c │ └── main.c │ ├── lto-archive-dylib │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── lto-archive-objc │ ├── Makefile │ ├── bar.m │ ├── baz.m │ ├── foo.c │ └── main.c │ ├── lto-dead_strip-all-hidden │ ├── Makefile │ └── bar.c │ ├── lto-dead_strip-coalesce │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── lto-dead_strip-inline-asm │ ├── Makefile │ └── bar.c │ ├── lto-dead_strip-objc │ ├── Makefile │ └── foo.m │ ├── lto-dead_strip-some-hidden │ ├── Makefile │ └── bar.c │ ├── lto-dead_strip-tentative │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── foo.c │ └── main.c │ ├── lto-dead_strip-unused │ ├── Makefile │ ├── bar.c │ └── main.c │ ├── lto-duplicate_symbols │ ├── Makefile │ ├── main.c │ ├── non-static.c │ └── static.c │ ├── lto-dylib-aliases │ ├── Makefile │ └── foo.c │ ├── lto-dylib-export_list │ ├── Makefile │ ├── bar.cxx │ ├── foo.cxx │ ├── foo.exp │ └── foo.h │ ├── lto-dynamic_export │ ├── Makefile │ └── main.c │ ├── lto-live_support_section │ ├── Makefile │ └── foo.c │ ├── lto-llvm-options │ ├── Makefile │ └── main.c │ ├── lto-objc-archive │ ├── Makefile │ ├── bar.h │ ├── bar.m │ ├── bar2.c │ ├── foo.h │ ├── foo.m │ ├── foo2.c │ └── main.m │ ├── lto-objc-image-info │ ├── Makefile │ └── main.m │ ├── lto-object_path │ ├── Makefile │ └── main.c │ ├── lto-preload-pie │ ├── Makefile │ ├── a.c │ ├── b.c │ └── main.c │ ├── lto-r │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── lto-rename_section │ ├── Makefile │ ├── a.c │ ├── b.c │ └── main.c │ ├── lto-rename_segment │ ├── Makefile │ ├── a.c │ ├── b.c │ └── main.c │ ├── lto-static-pie │ ├── Makefile │ ├── a.c │ ├── b.c │ └── main.c │ ├── lto-symbol-section-move │ ├── Makefile │ ├── foo.c │ ├── main.c │ ├── other.c │ ├── ram1.symbols │ └── rom1.symbols │ ├── lto-thin-mixed-weak-defs │ ├── Makefile │ ├── bar.cpp │ ├── foo.cpp │ ├── foo_impl.h │ └── main.cpp │ ├── lto-unexport-sym │ ├── Makefile │ ├── a.c │ ├── b.c │ └── unexp.list │ ├── lto-weak-native-override │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── lto-weak_import │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── main-stripped │ ├── Makefile │ ├── main.c │ └── main.exp │ ├── merge_zero_fill_sections │ ├── Makefile │ └── main.c │ ├── missing-option-args │ ├── Makefile │ └── comment.txt │ ├── multiple-entry-points │ ├── Makefile │ ├── comment.txt │ └── test.s │ ├── no-data-bundle │ ├── Makefile │ └── foo.c │ ├── no-dynamic-common │ ├── Makefile.newtest │ ├── a.c │ ├── comment.txt │ └── test.c │ ├── no-object-symbols │ ├── Makefile │ └── empty.s │ ├── no-uuid │ ├── Makefile │ ├── bar.c │ ├── comment.txt │ └── foo.c │ ├── no_zero_fill_sections │ ├── Makefile │ └── main.c │ ├── non-lazy-r │ ├── Makefile │ ├── foo.c │ └── other.c │ ├── non-lazy-sections-r │ ├── Makefile │ └── foo.s │ ├── objc-abi │ ├── Makefile │ └── test.m │ ├── objc-category-archive │ ├── Makefile │ ├── main.m │ ├── test.m │ └── test2.m │ ├── objc-category-class-property-mismatch │ ├── Makefile │ ├── cat.m │ └── class.m │ ├── objc-category-debug-notes │ ├── Makefile │ └── test.m │ ├── objc-category-optimize-external │ ├── Makefile │ ├── cat1.m │ ├── cat2.m │ └── foo.m │ ├── objc-category-optimize-load │ ├── Makefile │ ├── cat1.m │ └── foo.m │ ├── objc-category-optimize │ ├── Makefile │ ├── cat1.m │ ├── cat2.m │ └── foo.m │ ├── objc-category-warning │ ├── Makefile │ ├── cat.m │ ├── copycat.m │ └── foo.m │ ├── objc-class-alias │ ├── Makefile │ └── test.m │ ├── objc-class-patching-alias │ ├── Makefile │ ├── exported_symbols │ ├── foo.m │ └── foo_alias.c │ ├── objc-exported_symbols_list │ ├── Makefile │ ├── foo.exp │ └── foo.m │ ├── objc-literal-pointers-strip │ ├── Makefile │ └── test.m │ ├── objc-literal-pointers │ ├── Makefile │ └── test.m │ ├── objc-properties │ ├── Makefile │ └── test.m │ ├── objc-references │ ├── Makefile │ ├── comment.txt │ └── test.m │ ├── objc-selector-coalescing │ ├── Makefile │ ├── main.m │ └── other.m │ ├── objc-sort-selnames-heuristic │ ├── Makefile │ └── main.m │ ├── objc-stubs-objcmsgsend-dynamic-lookup │ ├── Makefile │ ├── a.out │ └── main.m │ ├── objc-stubs-selname-order │ ├── Makefile │ └── main.m │ ├── objc-visibility │ ├── Makefile │ ├── bar.h │ ├── bar.m │ ├── foo.h │ └── foo.m │ ├── operator-new │ ├── Makefile │ └── main.cxx │ ├── order_file-ans │ ├── Makefile │ ├── main.cxx │ ├── main.expected │ └── main.order │ ├── order_file-archive │ ├── Makefile │ ├── foo.c │ ├── main.c │ ├── main.expected │ └── main.order │ ├── order_file-thinlto │ ├── Makefile │ ├── test.c │ ├── test.expected │ ├── test.order │ ├── test2.c │ └── test3.c │ ├── order_file-zero-fill │ ├── Makefile │ ├── foo.c │ ├── main.c │ ├── main.expected │ └── main.order │ ├── order_file │ ├── Makefile │ ├── extra.s │ ├── main.c │ ├── main1.expected │ ├── main1.order │ ├── main2.expected │ ├── main2.order │ ├── main3.expected │ ├── main3.order │ ├── main4.expected │ └── main4.order │ ├── pagezero-alignment │ ├── Makefile │ └── main.c │ ├── pagezero-none-segaddr-zero │ ├── Makefile │ └── main.c │ ├── parse-cfi-and-symbols-at-section-end │ ├── Makefile │ ├── constant.s │ └── test.s │ ├── parse-cfi-anon-atom-split │ ├── Makefile │ └── test.s │ ├── parse-cfi-missing-atom-splits │ ├── Makefile │ └── test.s │ ├── pipelined-linking │ ├── Makefile │ ├── bar.c │ ├── cat.c │ └── foo.c │ ├── prebound-split-seg │ ├── Makefile │ ├── address_table │ └── bar.c │ ├── preload-fixup-chains │ ├── Makefile │ └── main.c │ ├── preload-section_order │ ├── Makefile │ ├── extra.s │ ├── main.c │ ├── main1.expected │ ├── main2.expected │ └── more.s │ ├── preload-segment_order │ ├── Makefile │ ├── a.c │ ├── b.c │ ├── main-segs.expected │ └── main.c │ ├── private-non-lazy │ ├── Makefile │ ├── bar.c │ ├── comment.txt │ ├── foo.c │ └── hello.c │ ├── re-export-and-use │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── foo.c │ └── pub.c │ ├── re-export-cases │ ├── Makefile │ ├── bar.c │ ├── baz.c │ └── foo.c │ ├── re-export-flag │ ├── Makefile │ ├── bar.c │ └── foo.c │ ├── re-export-layers │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── foo.c │ └── main.c │ ├── re-export-optimizations-indirect │ ├── Makefile │ ├── bar.c │ ├── foo.c │ ├── main.c │ ├── middle.c │ └── other.c │ ├── re-export-optimizations │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── re-export-relative-paths │ ├── Makefile │ ├── bar.c │ ├── baz.c │ ├── foo.c │ ├── main.c │ └── wrap.c │ ├── re-export-symbol │ ├── Makefile │ ├── bar.c │ ├── foo.c │ ├── foo.exp │ ├── foo2.exp │ ├── main1.c │ └── main2.c │ ├── re-export-weak │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── read-only-relocs │ ├── Makefile │ ├── foo.c │ ├── main.c │ ├── test.c │ ├── test_bind.c │ └── test_rebase.c │ ├── rebase-basic │ ├── Makefile │ ├── bar.m │ ├── comment.txt │ └── foo.c │ ├── reexport_symbols_list │ ├── Makefile │ ├── bar.c │ ├── bart.exp │ ├── foo.c │ ├── foo.exp │ ├── junk.exp │ └── main1.c │ ├── relocs-asm │ ├── Makefile │ ├── comment.txt │ └── relocs-asm.s │ ├── relocs-c │ ├── Makefile │ └── test.c │ ├── relocs-c2 │ ├── Makefile │ ├── comment.txt │ └── test.c │ ├── relocs-literals │ ├── Makefile │ └── test.c │ ├── relocs-literals2 │ ├── Makefile │ └── test.c │ ├── relocs-literals3 │ ├── Makefile │ ├── comment.txt │ └── test.c │ ├── relocs-neg-from-local │ ├── Makefile │ └── test.s │ ├── relocs-objc │ ├── Makefile │ ├── comment.txt │ └── test.m │ ├── sectcreate-dead_strip │ ├── Makefile │ ├── main.c │ └── sect_content │ ├── section-labels-zero-fill │ ├── Makefile │ ├── both.c │ ├── bss.c │ └── common.c │ ├── section-labels │ ├── Makefile │ └── main.c │ ├── section-names-long │ ├── Makefile │ ├── a.s │ ├── b.s │ ├── c.s │ └── main.c │ ├── segment-labels │ ├── Makefile │ ├── main.c │ └── test.c │ ├── segment-order │ ├── Makefile │ ├── expected.order │ ├── main.c │ ├── segJJJ.s │ ├── segKKK.s │ └── segLLL.s │ ├── shared-cache-dylib │ ├── Makefile │ └── foo.c │ ├── slow-x86-stubs │ ├── Makefile │ └── hello.c │ ├── sparse-versioned-framework │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── special-labels │ ├── Makefile │ ├── extra.s │ └── main.c │ ├── stack_addr_no_size │ ├── Makefile.newtest │ ├── comment.txt │ └── main.c │ ├── stack_size_no_addr │ ├── Makefile │ ├── comment.txt │ └── main.c │ ├── static-executable-fixupchains-section │ ├── Makefile │ └── test.c │ ├── static-executable-img-base-zeropage │ ├── Makefile │ └── test.c │ ├── static-executable-pie │ ├── Makefile │ ├── bad.c │ └── test.c │ ├── static-executable-weak-defines │ ├── Makefile │ └── test.c │ ├── static-executable │ ├── Makefile │ └── test.c │ ├── static-strip │ ├── Makefile.newtest │ ├── comment.txt │ └── test.c │ ├── strip-test2 │ ├── Makefile │ ├── comment.txt │ └── main.cxx │ ├── strip-test3 │ ├── Makefile.newtest │ ├── comment.txt │ └── main.cxx │ ├── strip_local │ ├── Makefile │ ├── foo.c │ └── hello.c │ ├── stripped-indirect-symbol-table │ ├── Makefile │ ├── a.c │ ├── b.c │ ├── c.c │ ├── func.c │ └── strip.list │ ├── stub-generation-weak │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── stub-generation │ ├── Makefile │ └── test.c │ ├── swift-force-load-sym-redirect-both │ ├── Makefile │ ├── client.c │ └── lib.c │ ├── swift-force-load-sym-redirect-other │ ├── Makefile │ ├── client.c │ └── lib.c │ ├── swift-force-load-sym-redirect │ ├── Makefile │ ├── client.c │ └── lib.c │ ├── swift-force-load-sym │ ├── Makefile │ ├── client.c │ └── lib.c │ ├── switch-jump-table │ ├── Makefile │ ├── interpose.exp │ ├── main.c │ └── switch.s │ ├── symbol-hiding-umbrella │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── symbol-move-and-section-rename │ ├── Makefile │ ├── foo.list │ ├── foo1.c │ ├── foo2.c │ ├── hot.list │ ├── main.c │ └── spec.list │ ├── symbol-moving │ ├── Makefile │ ├── aaa.c │ ├── anotb.c │ ├── bar.c │ ├── bbb.c │ ├── bnota.c │ ├── foo.c │ └── main.c │ ├── symbol-resolver-basic │ ├── Makefile │ └── foo.c │ ├── symbol-resolver-hidden │ ├── Makefile │ └── foo.c │ ├── symbol-section-move │ ├── Makefile │ ├── main.c │ ├── other.c │ ├── ram1.symbols │ └── rom1.symbols │ ├── symbol-warn-cpp-extern-c │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.cpp │ ├── synthetic-dylib-lc-order │ ├── Makefile │ ├── bar_moved.c │ ├── baz_moved.c │ └── main.c │ ├── tentative-and-archive-code │ ├── Makefile │ ├── foo_code.c │ ├── foo_data.c │ ├── foo_tent.c │ ├── junk.c │ └── main.c │ ├── tentative-and-archive │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── tentative-and-dylib │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── tentative-to-real-hidden │ ├── Makefile │ └── test.c │ ├── tentative-to-real-r │ ├── Makefile │ └── test.c │ ├── tentative-to-real │ ├── Makefile │ ├── comment.txt │ └── test.c │ ├── thumb-blx │ ├── Makefile │ └── test.c │ ├── thumb-pointer │ ├── Makefile │ ├── bar.c │ └── foo.c │ ├── tlv-basic │ ├── Makefile │ ├── get.s │ └── main.c │ ├── tlv-dead_strip │ ├── Makefile │ └── main.c │ ├── tlv-dylib │ ├── Makefile │ ├── foo.c │ └── main.c │ ├── tlv-r │ ├── Makefile │ └── foo.c │ ├── umbrella-dylib │ ├── Makefile │ ├── a.c │ ├── b.c │ ├── c.c │ └── main.c │ ├── umbrella-framework │ ├── Big │ ├── Makefile │ ├── a.c │ ├── b.c │ ├── c.c │ └── main.c │ ├── undefined-dynamic-lookup │ ├── Makefile │ └── main.c │ ├── unexported_symbols_list-r │ ├── Makefile │ ├── foo.c │ └── foo.exp │ ├── unstrippable-symbols │ ├── Makefile │ └── foo.c │ ├── utf16-nul │ ├── Makefile │ ├── other.s │ └── withnul.s │ ├── visibility-warning-dylib-v-archive │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── visibility-warning │ ├── Makefile │ ├── foo.c │ ├── foo_hidden.c │ ├── foo_weak.c │ └── foo_weak_hidden.c │ ├── weak-def-auto-hide │ ├── Makefile │ ├── main.c │ └── other.s │ ├── weak-def-flag │ ├── Makefile │ ├── main-strip-weak.c │ └── main.c │ ├── weak-def-hidden-and-global │ ├── Makefile │ ├── myglobal.c │ └── myhidden.s │ ├── weak-def-ordinal │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── weak-force │ ├── Makefile │ ├── foo.c │ ├── foo1.exp │ └── foo2.exp │ ├── weak_dylib │ ├── Makefile │ ├── bar.c │ ├── bar.h │ ├── data.c │ ├── foo.c │ ├── foo.h │ └── main.c │ ├── weak_import-addend │ ├── Makefile │ └── test.s │ ├── weak_import-disable │ ├── Makefile │ ├── foo.c │ ├── main.c │ └── main2.c │ ├── weak_import-force │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── weak_import-local │ ├── Makefile │ ├── foo.c │ ├── foo.h │ └── main.c │ ├── weak_import-r │ ├── Makefile │ ├── foo.h │ └── main.c │ ├── weak_import-undefined │ ├── Makefile │ └── weak.c │ ├── weak_import │ ├── Makefile │ ├── foo.c │ ├── foo.h │ └── main.c │ ├── weak_import2 │ ├── Makefile.newtest │ ├── comment.txt │ ├── foo.c │ ├── foo.h │ ├── foo1.c │ └── main.c │ ├── why_live │ ├── Makefile │ ├── bar.c │ ├── foo.c │ └── main.c │ ├── zero-fill │ ├── Makefile │ └── test.c │ ├── zero-fill2 │ ├── Makefile │ ├── comment.txt │ └── test.c │ └── zero-fill3 │ ├── Makefile │ ├── comment.txt │ └── test.c └── update.sh /doc/design/bindings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keith/ld64/7042a5f6bea71bc33c0a083911e03f86704f2e23/doc/design/bindings.png -------------------------------------------------------------------------------- /doc/design/hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keith/ld64/7042a5f6bea71bc33c0a083911e03f86704f2e23/doc/design/hello.png -------------------------------------------------------------------------------- /doc/man/man1/ld64.1: -------------------------------------------------------------------------------- 1 | .so man1/ld-classic.1 2 | -------------------------------------------------------------------------------- /unit-tests/bin/fail-if-exit-non-zero.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use strict; 4 | 5 | my $test_name = ""; 6 | if ( exists $ENV{UNIT_TEST_NAME} ) { 7 | $test_name = $ENV{UNIT_TEST_NAME}; 8 | } 9 | 10 | if(system(@ARGV) != 0) 11 | { 12 | printf("FAIL $test_name\n"); 13 | exit 1; 14 | } 15 | 16 | exit 0; 17 | -------------------------------------------------------------------------------- /unit-tests/bin/fail-if-no-stdin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | # 4 | # Usage: 5 | # 6 | # command | ${FAIL_IF_EMPTY} 7 | # 8 | 9 | use strict; 10 | 11 | my $test_name = ""; 12 | if ( exists $ENV{UNIT_TEST_NAME} ) { 13 | $test_name = $ENV{UNIT_TEST_NAME}; 14 | } 15 | 16 | if( eof STDIN ) 17 | { 18 | printf("FAIL $test_name\n"); 19 | exit 1; 20 | } 21 | 22 | exit 0; 23 | -------------------------------------------------------------------------------- /unit-tests/bin/fail-if-stdin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | # 4 | # Usage: 5 | # 6 | # command | ${FAIL_IF_STDIN} 7 | # 8 | 9 | use strict; 10 | 11 | my $test_name = ""; 12 | if ( exists $ENV{UNIT_TEST_NAME} ) { 13 | $test_name = $ENV{UNIT_TEST_NAME}; 14 | } 15 | 16 | if( eof STDIN ) 17 | { 18 | exit 0; 19 | } 20 | 21 | printf("FAIL $test_name\n"); 22 | exit 1; 23 | -------------------------------------------------------------------------------- /unit-tests/bin/pass-iff-exit-zero.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | # 4 | # Usage: 5 | # 6 | # ${PASS_IFF} command 7 | # 8 | 9 | use strict; 10 | 11 | my $test_name = ""; 12 | if ( exists $ENV{UNIT_TEST_NAME} ) { 13 | $test_name = $ENV{UNIT_TEST_NAME}; 14 | } 15 | 16 | if(0 != system(@ARGV)) 17 | { 18 | printf("FAIL $test_name\n"); 19 | exit 1; 20 | } 21 | 22 | printf("PASS $test_name\n"); 23 | exit 0; 24 | -------------------------------------------------------------------------------- /unit-tests/bin/pass-iff-no-stdin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | # 4 | # Usage: 5 | # 6 | # command | ${PASS_IFF_EMPTY} 7 | # 8 | 9 | use strict; 10 | 11 | my $test_name = ""; 12 | if ( exists $ENV{UNIT_TEST_NAME} ) { 13 | $test_name = $ENV{UNIT_TEST_NAME}; 14 | } 15 | 16 | if( eof STDIN ) 17 | { 18 | printf("PASS $test_name\n"); 19 | exit 0; 20 | } 21 | 22 | printf("FAIL $test_name\n"); 23 | exit 1; 24 | -------------------------------------------------------------------------------- /unit-tests/bin/pass-iff-stdin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | # 4 | # Usage: 5 | # 6 | # command | ${PASS_IFF_STDIN} 7 | # 8 | 9 | use strict; 10 | 11 | my $test_name = ""; 12 | if ( exists $ENV{UNIT_TEST_NAME} ) { 13 | $test_name = $ENV{UNIT_TEST_NAME}; 14 | } 15 | 16 | if( eof STDIN ) 17 | { 18 | printf("FAIL $test_name\n"); 19 | exit 1 20 | } 21 | 22 | printf("PASS $test_name\n"); 23 | exit 0; 24 | 25 | -------------------------------------------------------------------------------- /unit-tests/src/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: ../bin/results-to-xml ../bin/xmlparser 3 | 4 | ../bin/results-to-xml: results-to-xml.cpp 5 | g++ -g -O -Wall $< -o ../bin/results-to-xml 6 | 7 | ../bin/xmlparser: 8 | cd xmlparser; xcodebuild -alltargets 9 | cp -p xmlparser/build/Release/xmlparser ../bin/. 10 | -------------------------------------------------------------------------------- /unit-tests/src/xmlparser/xmlparser_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'xmlparser' target in the 'xmlparser' project. 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/16-byte-alignment/comment.txt: -------------------------------------------------------------------------------- 1 | Test 16 byte alignment with -O2 optimization. Radar #4662185 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/Lpath/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int foo() { return 0; } 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/Lpath/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern int foo(); 3 | 4 | int main() 5 | { 6 | foo(); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/absolute-symbol/abs.s: -------------------------------------------------------------------------------- 1 | 2 | .globl _myAbs 3 | #if __LP64__ 4 | _myAbs = 0x102345678 5 | #else 6 | _myAbs = 0xfe000000 7 | #endif 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/absolute-symbol/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern int* myAbs; 3 | 4 | int main() { return *myAbs; } 5 | 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/alias-basic/main.c: -------------------------------------------------------------------------------- 1 | extern void bar(); 2 | extern int result; 3 | 4 | int myresult = 1; 5 | 6 | int mymain() 7 | { 8 | bar(); 9 | return result; 10 | } 11 | 12 | void mybar() 13 | { 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/alias-command-line/aliases.txt: -------------------------------------------------------------------------------- 1 | _foo _fooalt 2 | # comment 3 | _foo _fooalt2 4 | 5 | _hidden _glob 6 | 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/align-atom-in-page/foo.s: -------------------------------------------------------------------------------- 1 | .section __TEXT,__text,regular,pure_instructions 2 | .global _foo 3 | .p2align 2 4 | _foo: 5 | .zero 4 6 | 7 | .section __DATA_CONST,__data 8 | 9 | .zero 1 10 | 11 | _arr: 12 | .zero 7 13 | .quad _foo 14 | 15 | .subsections_via_symbols 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/align-atom-in-page/foo_align.s: -------------------------------------------------------------------------------- 1 | .section __TEXT,__text,regular,pure_instructions 2 | .global _foo 3 | .p2align 2 4 | _foo: 5 | .zero 4 6 | 7 | .section __DATA_CONST,__data 8 | .p2align 3 9 | 10 | .zero 1 11 | 12 | _arr: 13 | .zero 7 14 | .quad _foo 15 | 16 | .subsections_via_symbols 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/align-modulus/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to verify that the modules of symbol _b is maintained. The address for _b must be 2 | 3 mod 16. Therefore the last hexdigit of the address must be 3. 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/align-modulus/foo.exp: -------------------------------------------------------------------------------- 1 | _foo 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/all-load-file-sources/bar.c: -------------------------------------------------------------------------------- 1 | int bar() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/all-load-file-sources/baz.c: -------------------------------------------------------------------------------- 1 | int baz() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/all-load-file-sources/filelist: -------------------------------------------------------------------------------- 1 | baz.lib 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/all-load-file-sources/foo.c: -------------------------------------------------------------------------------- 1 | int foo() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/all-load-file-sources/main.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | return 0; 3 | } 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/allow-stack-execute/comment.txt: -------------------------------------------------------------------------------- 1 | Test the we set the stack execution bit properly. 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/allow-stack-execute/foo.c: -------------------------------------------------------------------------------- 1 | int main (void) 2 | { 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/allow_heap_execute/main.c: -------------------------------------------------------------------------------- 1 | int main(void) 2 | { 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/allowable-client/bar.c: -------------------------------------------------------------------------------- 1 | extern int foo (); 2 | 3 | int bar (void) 4 | { 5 | return foo(); 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/allowable-client/baz.c: -------------------------------------------------------------------------------- 1 | extern int foo (); 2 | 3 | int bar (void) 4 | { 5 | return foo(); 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/allowable-client/comment.txt: -------------------------------------------------------------------------------- 1 | Test that the -allowable_client and -client options work when linking against subframeworks. 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/allowable-client/foo.c: -------------------------------------------------------------------------------- 1 | int foo (void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/allowable-client/main.c: -------------------------------------------------------------------------------- 1 | extern int foo (); 2 | 3 | int main (void) 4 | { 5 | return foo(); 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/alt-entry/foo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int foo() 4 | { 5 | fprintf(stdout, "hello foo\n"); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/alt-entry/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int mymain() 4 | { 5 | fprintf(stdout, "hello mymain\n"); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-ObjC-unexported/bar.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foobar : NSObject 4 | @end 5 | 6 | void other() 7 | { 8 | [[Foobar alloc] init]; 9 | } 10 | 11 | void bar() 12 | { 13 | } 14 | 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-ObjC-unexported/foo.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | @end 5 | 6 | @implementation Foo 7 | @end 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-ObjC-unexported/main.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void bar(); 4 | 5 | int main() 6 | { 7 | bar(); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-ObjC-unexported/main.nexp: -------------------------------------------------------------------------------- 1 | _bar 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-ObjC/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar() { return 0; } 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-ObjC/baz.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Baz : NSObject 4 | @end 5 | 6 | @implementation Baz 7 | @end 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-ObjC/foo.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | @end 5 | 6 | @implementation Foo 7 | @end 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-basic/bar.c: -------------------------------------------------------------------------------- 1 | int bar() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-basic/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that .o files can be found in archives. 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-basic/foo.c: -------------------------------------------------------------------------------- 1 | int foo() { return 1; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-duplicate/bar.c: -------------------------------------------------------------------------------- 1 | int bar() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-duplicate/foo.c: -------------------------------------------------------------------------------- 1 | int foo() { return 1; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-force-load/bar.c: -------------------------------------------------------------------------------- 1 | void bar() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-force-load/bat.c: -------------------------------------------------------------------------------- 1 | void bat() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-force-load/baz.c: -------------------------------------------------------------------------------- 1 | void baz() {} 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-force-load/foo.c: -------------------------------------------------------------------------------- 1 | void foo() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-force-load/main.c: -------------------------------------------------------------------------------- 1 | 2 | int main() 3 | { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-init-order/bar.c: -------------------------------------------------------------------------------- 1 | int bar() { return 0; } 2 | 3 | __attribute__((constructor)) 4 | void bar_init() { } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-init-order/bar2.c: -------------------------------------------------------------------------------- 1 | int bar2() { return 0; } 2 | 3 | __attribute__((constructor)) 4 | void bar2_init() { } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-init-order/bar3.c: -------------------------------------------------------------------------------- 1 | int bar3() { return 0; } 2 | 3 | __attribute__((constructor)) 4 | void bar3_init() { } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-init-order/foo.c: -------------------------------------------------------------------------------- 1 | int foo() { return 1; } 2 | 3 | __attribute__((constructor)) 4 | void foo_init() { } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-init-order/foo2.c: -------------------------------------------------------------------------------- 1 | int foo2() { return 1; } 2 | 3 | __attribute__((constructor)) 4 | void foo2_init() { } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-init-order/foo3.c: -------------------------------------------------------------------------------- 1 | int foo3() { return 1; } 2 | 3 | __attribute__((constructor)) 4 | void foo3_init() { } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-order/bar.c: -------------------------------------------------------------------------------- 1 | int bar() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-order/bar2.c: -------------------------------------------------------------------------------- 1 | int bar2() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-order/bar3.c: -------------------------------------------------------------------------------- 1 | int bar3() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-order/expected.order: -------------------------------------------------------------------------------- 1 | _bar3 2 | _bar2 3 | _bar 4 | _foo 5 | _foo2 6 | _foo3 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-order/foo.c: -------------------------------------------------------------------------------- 1 | int foo() { return 1; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-order/foo2.c: -------------------------------------------------------------------------------- 1 | int foo2() { return 1; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-order/foo3.c: -------------------------------------------------------------------------------- 1 | int foo3() { return 1; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-r-ObjC/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar() { return 0; } 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-r-ObjC/baz.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Baz : NSObject 4 | @end 5 | 6 | @implementation Baz 7 | @end 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-r-ObjC/cat.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface NSObject(Cat) 4 | @end 5 | 6 | @implementation NSObject(Cat) 7 | @end 8 | 9 | @interface NSObject(Dog) 10 | @end 11 | 12 | @implementation NSObject(Dog) 13 | @end 14 | 15 | void mycatfunc() {} 16 | 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-r-ObjC/foo.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | @end 5 | 6 | @implementation Foo 7 | @end 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-weak/bar.c: -------------------------------------------------------------------------------- 1 | int bar() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-weak/baz.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | // intentionally not-weak 5 | int baz() 6 | { 7 | return 1; 8 | } 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-weak/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test if the linker already has a weak definition 2 | it does not try to find another copy in an archive 3 | 4 | There are two case to test: 5 | 1) both the main .o files and the archive have the same weak symbol (_foo) 6 | 2) main.o has a weak symbol and the archive has a non-weak symbol (_baz) 7 | In both cases the linker should ignore the archive. 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/archive-weak/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void collisionChecker() { } 4 | 5 | 6 | int __attribute__((weak)) foo() 7 | { 8 | collisionChecker(); 9 | return 1; 10 | } 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/bind_at_load/bar.c: -------------------------------------------------------------------------------- 1 | 2 | void bar() {} 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/bind_at_load/foo.c: -------------------------------------------------------------------------------- 1 | 2 | void foo() {} 3 | void foo2() {} 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/bind_at_load/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void foo(); 4 | extern void foo2() __attribute__((weak_import)); 5 | extern void bar(); 6 | 7 | int main() 8 | { 9 | foo(); 10 | bar(); 11 | if ( &foo2 != NULL ) 12 | foo2(); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/blank-stubs/comment.txt: -------------------------------------------------------------------------------- 1 | Test that blank stubs are handled properly 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/blank-stubs/foo.c: -------------------------------------------------------------------------------- 1 | int foo (void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/blank-stubs/main.c: -------------------------------------------------------------------------------- 1 | 2 | int main (void) 3 | { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/branch-distance/bar.s: -------------------------------------------------------------------------------- 1 | 2 | .text 3 | .align 4 4 | 5 | #if __thumb__ 6 | .thumb_func _bar 7 | .code 16 8 | #endif 9 | 10 | .globl _bar 11 | _bar: 12 | nop 13 | #if __arm__ 14 | bl _foo 15 | blx _foo 16 | // b _foo 17 | #endif 18 | 19 | 20 | 21 | 22 | .subsections_via_symbols 23 | -------------------------------------------------------------------------------- /unit-tests/test-cases/branch-interworking/myarm.s: -------------------------------------------------------------------------------- 1 | 2 | .text 3 | .align 4 4 | #if __arm__ 5 | .code 32 6 | .align 2 7 | #endif 8 | 9 | .globl _myarm 10 | _myarm: 11 | nop 12 | #if __arm__ 13 | //bl _mythumb 14 | b _mythumb 15 | #elif __i386__ || __x86_64__ 16 | jmp _mythumb 17 | #endif 18 | 19 | 20 | .subsections_via_symbols 21 | -------------------------------------------------------------------------------- /unit-tests/test-cases/branch-interworking/mythumb.s: -------------------------------------------------------------------------------- 1 | 2 | .text 3 | .align 4 4 | _junk: 5 | nop 6 | nop 7 | nop 8 | nop 9 | #if __arm__ 10 | .syntax unified 11 | .thumb_func _mythumb 12 | .code 16 13 | #endif 14 | 15 | .globl _mythumb 16 | _mythumb: 17 | nop 18 | #if __arm__ 19 | //bl _myarm 20 | b.w _myarm 21 | #elif __i386__ || __x86_64__ 22 | jmp _myarm 23 | #endif 24 | 25 | 26 | .subsections_via_symbols 27 | -------------------------------------------------------------------------------- /unit-tests/test-cases/branch-islands/extra.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void back(); 4 | 5 | void foo() 6 | { 7 | fprintf(stdout, "foo\n"); 8 | back(); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/branch-islands/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void foo(); 4 | 5 | int main() 6 | { 7 | fprintf(stdout, "hello\n"); 8 | foo(); 9 | return 0; 10 | } 11 | 12 | void back() 13 | { 14 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/branch-long/bar.s: -------------------------------------------------------------------------------- 1 | 2 | #if __arm__ 3 | 4 | .section __MY,__text,regular,pure_instructions 5 | .align 4 6 | 7 | #if __thumb__ 8 | .thumb_func _bar 9 | .code 16 10 | #endif 11 | .globl _bar 12 | _bar: 13 | nop 14 | bl _foo 15 | blx _foo2 16 | bl _myweak1 17 | 18 | 19 | #endif // __arm__ 20 | 21 | 22 | 23 | .subsections_via_symbols 24 | -------------------------------------------------------------------------------- /unit-tests/test-cases/branch-long/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int x = 1; 3 | int y = 2; 4 | 5 | __attribute__((weak)) 6 | void myweak1() 7 | { 8 | } 9 | 10 | int foo() 11 | { 12 | myweak1(); 13 | return 1; 14 | } 15 | 16 | int foo1() 17 | { 18 | return x; 19 | } 20 | 21 | int foo2() 22 | { 23 | return y; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cfstring-and-cstring/Makefile: -------------------------------------------------------------------------------- 1 | TESTROOT = ../.. 2 | include ${TESTROOT}/include/common.makefile 3 | 4 | SHELL = bash # use bash shell so we can redirect just stderr 5 | 6 | 7 | run: all 8 | 9 | all: 10 | ${CC} ${CCFLAGS} foo.c bar.c -Os -o foo -framework CoreFoundation 11 | ${PASS_IFF_GOOD_MACHO} foo 12 | 13 | clean: 14 | rm -rf foo 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cfstring-and-cstring/bar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | // 5 | // llvm may make cfstring that has backing store of kTest 6 | // 7 | 8 | 9 | const char kTest[] = "test"; 10 | 11 | void bar() 12 | { 13 | CFStringGetLength(CFSTR("test")); 14 | } 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cfstring-and-cstring/foo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void bar(); 4 | 5 | int main() 6 | { 7 | CFStringGetLength(CFSTR("stuff")); 8 | bar(); 9 | return 0; 10 | } 11 | 12 | 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cfstring-coalesce/bar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | CFStringRef OtherCFString = CFSTR("other"); 4 | 5 | void bar() 6 | { 7 | CFStringGetLength(CFSTR("live")); 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cfstring-coalesce/foo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void bar(); 4 | 5 | extern CFStringRef OtherCFString; 6 | 7 | void foo() 8 | { 9 | CFStringGetLength(CFSTR("hello")); 10 | CFStringGetLength(CFSTR("world")); 11 | CFStringGetLength(OtherCFString); 12 | } 13 | 14 | 15 | int main() 16 | { 17 | CFStringGetLength(CFSTR("live")); 18 | bar(); 19 | return 0; 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cfstring-utf16/bar.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | void bar() 5 | { 6 | CFStringGetLength(CFSTR("über")); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cfstring-utf16/foo.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void bar(); 4 | 5 | void foo() 6 | { 7 | CFStringGetLength(CFSTR("hello")); 8 | CFStringGetLength(CFSTR("überhund")); 9 | } 10 | 11 | 12 | int main() 13 | { 14 | CFStringGetLength(CFSTR("über")); 15 | CFStringGetLength(CFSTR("überhund")); 16 | bar(); 17 | return 0; 18 | } 19 | 20 | 21 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-abs/.mod_init_func: -------------------------------------------------------------------------------- 1 | .long 0x12340000 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-abs/init.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .mod_init_func 4 | #if __LP64__ 5 | .quad 0x7FFF123400000000 6 | #else 7 | .long 0x12340000 8 | #endif 9 | 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-abs/main.c: -------------------------------------------------------------------------------- 1 | int main() { return 0; } 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-abs/term.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .mod_term_func 4 | #if __LP64__ 5 | .quad 0x7FFF123400000000 6 | #else 7 | .long 0x12340000 8 | #endif 9 | 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-bind/.mod_init_func: -------------------------------------------------------------------------------- 1 | .long 0x12340000 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-bind/init.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .mod_init_func 4 | #if __LP64__ 5 | .quad _malloc + 0x100000010 6 | #else 7 | .long _malloc + 0x1010 8 | #endif 9 | 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-bind/main.c: -------------------------------------------------------------------------------- 1 | int main() { return 0; } 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-bind/term.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .mod_term_func 4 | #if __LP64__ 5 | .quad _malloc + 0x100000010 6 | #else 7 | .long _malloc + 0x1010 8 | #endif 9 | 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-no-rebase/.mod_init_func: -------------------------------------------------------------------------------- 1 | .long 0x12340000 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-no-rebase/init.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .mod_init_func 4 | #if __LP64__ 5 | .quad 0x100000010 6 | #else 7 | .long 0x1010 8 | #endif 9 | 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-no-rebase/main.c: -------------------------------------------------------------------------------- 1 | int main() { return 0; } 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/check-init-no-rebase/term.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .mod_term_func 4 | #if __LP64__ 5 | .quad 0x100000010 6 | #else 7 | .long 0x1010 8 | #endif 9 | 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/coalesce-force/foo.exp: -------------------------------------------------------------------------------- 1 | _foo1 2 | _wild* 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/coalesce_weak_def_in_dylib/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | __attribute__((weak)) void wfoo() {} 4 | void foo() {} 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/coalesce_weak_def_in_dylib/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | extern void wfoo(); 4 | 5 | void* pfoo = &foo; 6 | void* pwfoo = &wfoo; 7 | 8 | int main (void) 9 | { 10 | if (pfoo != &foo) 11 | return 1; 12 | if (pwfoo != &wfoo) 13 | return 1; 14 | 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /unit-tests/test-cases/code-dedup-order/bar.cpp: -------------------------------------------------------------------------------- 1 | struct Bar { 2 | 3 | int sum; 4 | 5 | Bar(int a, int b) { sum = a + b; } 6 | 7 | template 8 | T getSum() { return sum; } 9 | }; 10 | 11 | template 12 | T bar_impl(T a, T b) { 13 | return Bar(a, b).getSum(); 14 | } 15 | 16 | int bar(int a, int b) { 17 | return bar_impl(a, b); 18 | } 19 | -------------------------------------------------------------------------------- /unit-tests/test-cases/code-dedup-order/bar.h: -------------------------------------------------------------------------------- 1 | struct Bar { 2 | 3 | int sum; 4 | 5 | Bar(int a, int b) { sum = a + b; } 6 | 7 | template 8 | T getSum() { return sum; } 9 | }; 10 | 11 | template 12 | T bar_impl(T a, T b) { 13 | return Bar(a, b).getSum(); 14 | } 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/code-dedup-order/baz.cpp: -------------------------------------------------------------------------------- 1 | struct Baz { 2 | 3 | int sum; 4 | 5 | Baz(int a, int b) { sum = a + b; } 6 | }; 7 | 8 | int baz(int a, int b) { 9 | return Baz(a, b).sum; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/code-signed-object-file/foo.c: -------------------------------------------------------------------------------- 1 | void foo() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-alignment/foo.s: -------------------------------------------------------------------------------- 1 | 2 | .comm _mycomm64aligned,15,6 3 | .comm _mycomm16kaligned,256,14 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-coalesced-dead_strip/a.c: -------------------------------------------------------------------------------- 1 | #include "c.h" 2 | 3 | float aa() { return bar; } 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-coalesced-dead_strip/b.c: -------------------------------------------------------------------------------- 1 | #include "c.h" 2 | 3 | float bb() { return bar; } 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-coalesced-dead_strip/c.c: -------------------------------------------------------------------------------- 1 | 2 | const float bar = 1.0; 3 | 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-coalesced-dead_strip/c.h: -------------------------------------------------------------------------------- 1 | 2 | // missing extern 3 | const float bar; 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-mixed/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar; 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-mixed/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int foo; 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-only-concrete-overrides/libfoo.c: -------------------------------------------------------------------------------- 1 | int foo; 2 | int bar = 5; 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-only-concrete-overrides/libfoo_tent.c: -------------------------------------------------------------------------------- 1 | int foo; 2 | int bar; 3 | 4 | int tent_marker = 0; 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-only-concrete-overrides/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int foo; 4 | int bar; 5 | 6 | int main() { 7 | printf("foo: %d\n", foo); 8 | printf("bar: %d\n", bar); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-only-concrete-overrides/main_extern.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern int foo; 4 | extern int bar; 5 | 6 | int main() { 7 | printf("foo: %d\n", foo); 8 | printf("bar: %d\n", bar); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-order/bar.c: -------------------------------------------------------------------------------- 1 | int ddd_common; 2 | int iii_common[4]; 3 | int bbb_common[4]; 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-order/baz.c: -------------------------------------------------------------------------------- 1 | int fff_common; 2 | int iii_common[4]; 3 | int ttt_common; 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-order/expected.order: -------------------------------------------------------------------------------- 1 | _fff_common 2 | _iii_common 3 | _ttt_common 4 | _aaa_common 5 | _eee_common 6 | _ggg_common 7 | _bbb_common 8 | _ddd_common 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-order/foo.c: -------------------------------------------------------------------------------- 1 | int aaa_common; 2 | int ggg_common[4]; 3 | int eee_common; 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-order/main.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main() { return 0; } 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-private-extern-overrides/libfoo.c: -------------------------------------------------------------------------------- 1 | int foo; 2 | int bar = 5; 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/commons-private-extern-overrides/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int foo; 4 | int bar; 5 | 6 | int main() { 7 | printf("foo: %d\n", foo); 8 | printf("bar: %d\n", bar); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cpu-sub-types-preference/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #if AAA 4 | void aaa() {} 5 | #endif 6 | 7 | #if BBB 8 | void bbb() {} 9 | #endif 10 | 11 | #if CCC 12 | void ccc() {} 13 | #endif 14 | 15 | #if DDD 16 | void ddd() {} 17 | #endif 18 | 19 | #if EEE 20 | void eee() {} 21 | #endif 22 | 23 | #if FFFF 24 | void fff() {} 25 | #endif 26 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cpu-sub-types/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is validate cpu subtypes processsing for PowerPC 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cpu-sub-types/foo.c: -------------------------------------------------------------------------------- 1 | void foo() 2 | { 3 | } 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cpu-sub-types/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void foo(); 4 | extern void bar(); 5 | 6 | int main() 7 | { 8 | foo(); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cstring-alt-segment/custom.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | .section __MYSEG, __cstring, cstring_literals 5 | LC1: .ascii "hello\0" 6 | LC2: .ascii "bye\0" 7 | LC3: .ascii "hello\0" 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cstring-alt-segment/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | printf("hello"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cstring-empty-labeled/foo.s: -------------------------------------------------------------------------------- 1 | .cstring 2 | LC2: 3 | .ascii "bye\0" 4 | .ascii "\0" 5 | .ascii "\0" 6 | 7 | .globl _empty 8 | _empty: 9 | .ascii "\0" 10 | 11 | LC0: 12 | .ascii "hello\0" 13 | .ascii "\0" 14 | .ascii "\0" 15 | .ascii "\0" 16 | 17 | LC1: 18 | .ascii "\0" 19 | 20 | 21 | .subsections_via_symbols 22 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cstring-labels/bar.c: -------------------------------------------------------------------------------- 1 | const char* kBar = "hello"; 2 | const char* kBar2 = "there"; 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/cstring-labels/foo.c: -------------------------------------------------------------------------------- 1 | 2 | void func() {} 3 | 4 | const char kFoo[] = "foo"; 5 | 6 | const char* kFoo2 = "hello"; 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/custom-segment-layout/main.c: -------------------------------------------------------------------------------- 1 | 2 | int x = 5; 3 | 4 | int main() 5 | { 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/custom-segment-layout/zero.s: -------------------------------------------------------------------------------- 1 | 2 | .section __MYZEROPAGE,_data 3 | _min: .long 0 4 | 5 | #if __arm__ 6 | .zerofill __MYZEROPAGE,__zerofill,_padding,536870910 7 | #else 8 | .zerofill __MYZEROPAGE,__zerofill,_padding,2147483644 9 | #endif 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/data-in-code/test.s: -------------------------------------------------------------------------------- 1 | 2 | .text 3 | 4 | _foo: 5 | nop 6 | nop 7 | .data_region 8 | nop 9 | nop 10 | nop 11 | .end_data_region 12 | .data_region jt8 13 | nop 14 | nop 15 | .end_data_region 16 | .data_region jt16 17 | nop 18 | nop 19 | .end_data_region 20 | .data_region jt32 21 | nop 22 | nop 23 | .end_data_region 24 | nop 25 | nop 26 | 27 | 28 | .subsections_via_symbols 29 | 30 | 31 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive-duplicate-def/bar.c: -------------------------------------------------------------------------------- 1 | 2 | void bar() { } 3 | 4 | int baz() 5 | { 6 | return -1; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive-duplicate-def/foo.c: -------------------------------------------------------------------------------- 1 | 2 | void foo() { } 3 | 4 | extern void bar(); 5 | 6 | void deadwood() 7 | { 8 | bar(); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive-duplicate-def/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | 4 | int baz() 5 | { 6 | return 0; 7 | } 8 | 9 | int main() 10 | { 11 | foo(); 12 | return 0; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive-eh/bar.cxx: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void doit() 5 | { 6 | printf("hello there %s\n", "world"); 7 | 8 | } 9 | 10 | void bar() 11 | { 12 | doit(); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive-eh/foo.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | __attribute__((weak)) void doit() 4 | { 5 | printf("hello %s\n", "world"); 6 | } 7 | 8 | 9 | void foo() 10 | { 11 | doit(); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive-eh/main.cxx: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | extern void bar(); 4 | 5 | int main() 6 | { 7 | foo(); 8 | bar(); 9 | return 0; 10 | } 11 | 12 | 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive-global/foo.c: -------------------------------------------------------------------------------- 1 | 2 | static int foo_count = 0; 3 | static int bar_count = 0; 4 | static int baz_count = 0; 5 | 6 | 7 | void foo() { ++foo_count; } 8 | 9 | void bar() { ++bar_count; } 10 | 11 | void __attribute__((visibility("hidden"))) 12 | baz() { ++baz_count; } 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive-weak-override/bar.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void bar() 4 | { 5 | } 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive-weak-override/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | 4 | 5 | // strong definition of foo overrides weak definition 6 | // in main.c, but this foo needs bar() 7 | void foo() 8 | { 9 | bar(); 10 | } 11 | 12 | void loadme() 13 | { 14 | } 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive-weak-override/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void loadme(); 3 | 4 | 5 | void bad() 6 | { 7 | } 8 | 9 | // foo is first found be live here 10 | // then the use of loadme causes libfoo.a(foo.o) 11 | // to be loaded which overrides foo 12 | __attribute__((weak)) void foo() 13 | { 14 | bad(); 15 | } 16 | 17 | int main() 18 | { 19 | foo(); 20 | loadme(); 21 | foo(); 22 | return 0; 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive-weak/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern void good(); 3 | 4 | void foo() 5 | { 6 | good(); 7 | } 8 | 9 | void loadme() 10 | { 11 | // foo(); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test that -dead_strip removes unreference code/data from archives 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-archive/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() {} 4 | 5 | 6 | int my_common; 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-coalesced-order/foo.cpp: -------------------------------------------------------------------------------- 1 | static int bar() { return 0; } 2 | 3 | template 4 | struct Foo { 5 | 6 | T foo(void) { 7 | return bar(); 8 | } 9 | }; 10 | 11 | __attribute__((constructor)) 12 | int other() { 13 | return Foo().foo(); 14 | } 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-entry-archive/bar.c: -------------------------------------------------------------------------------- 1 | 2 | void bar() {} 3 | 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-entry-archive/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() {} 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-init-archive/bar.c: -------------------------------------------------------------------------------- 1 | 2 | void bar() {} 3 | 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-init-archive/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() {} 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-initializers/main.cxx: -------------------------------------------------------------------------------- 1 | 2 | int main() 3 | { 4 | return 0; 5 | } 6 | 7 | 8 | 9 | void dead_door_knob() { } 10 | 11 | 12 | extern "C" int ctr(); 13 | extern "C" void dtr(); 14 | 15 | 16 | int ctr() { return 10; } 17 | void dtr() { } 18 | 19 | 20 | #if __STATIC__ 21 | extern "C" void __cxa_atexit(); 22 | void __cxa_atexit() {} 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-initializers/other.cxx: -------------------------------------------------------------------------------- 1 | 2 | extern "C" int ctr(); 3 | extern "C" void dtr(); 4 | 5 | class Foo 6 | { 7 | public: 8 | Foo() : field(ctr()) { } 9 | ~Foo() { dtr(); } 10 | private: 11 | int field; 12 | }; 13 | 14 | 15 | Foo f1; 16 | Foo f2; 17 | 18 | 19 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-weak-coalesce/baz.c: -------------------------------------------------------------------------------- 1 | void baz() 2 | { 3 | } 4 | 5 | 6 | #include "foo.c" 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip-weak-coalesce/main.c: -------------------------------------------------------------------------------- 1 | 2 | // baz is in a lazily loaded archive 3 | extern void baz(); 4 | 5 | int main() 6 | { 7 | baz(); 8 | return 0; 9 | } 10 | 11 | 12 | #include "foo.c" 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check -dead_strip 2 | 3 | 1) in a main executable, dead globals are removed 4 | 2) in a dylib/bundle with -exported_symbols_list, dead globals are removed 5 | 3) in a dylib/bundle without -exported_symbols_list, dead globals are *not* removed 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip/deadwood.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | // deadwood() is local to its linkage unit and is unsed, 4 | // so reference to undef() is ok 5 | 6 | extern void undef(); 7 | 8 | void dead_wood() __attribute__((visibility("hidden"))); 9 | void dead_wood() { undef(); } 10 | 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip/main.exp: -------------------------------------------------------------------------------- 1 | _main 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip_dylibs/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip_dylibs/baz.c: -------------------------------------------------------------------------------- 1 | 2 | int baz (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip_dylibs/foo.c: -------------------------------------------------------------------------------- 1 | int foo (void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip_dylibs/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | 4 | int main() 5 | { 6 | #if CALL_BAR 7 | bar(); 8 | #endif 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strip_section_attribute/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to check that -dead_strip does not remove 2 | atoms in sections with the S_ATTR_NO_DEAD_STRIP bit set 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strippable_dylib/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strippable_dylib/baz.c: -------------------------------------------------------------------------------- 1 | 2 | int baz (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strippable_dylib/foo.c: -------------------------------------------------------------------------------- 1 | int foo (void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dead_strippable_dylib/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | 4 | int main() 5 | { 6 | foo(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dependency-logging/foo.c: -------------------------------------------------------------------------------- 1 | void foo() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dependency-logging/main.c: -------------------------------------------------------------------------------- 1 | extern void foo(); 2 | 3 | int main() 4 | { 5 | foo(); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/dirty-data-alt-entry/1.dirty: -------------------------------------------------------------------------------- 1 | _sym1 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dirty-data-alt-entry/2.dirty: -------------------------------------------------------------------------------- 1 | _sym2 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dirty-data-alt-entry/test.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | .data 7 | _foo: .quad 0,0,0 8 | 9 | # note: the .alt_entry means sym2 needs to stay pinned to sym1 10 | .globl _sym1 11 | .globl _sym2 12 | .alt_entry _sym2 13 | 14 | _sym1: .quad 0,0 15 | _sym2: .quad 0,0 16 | 17 | .globl _sym3 18 | _sym3: .quad 0,0 19 | 20 | 21 | .subsections_via_symbols 22 | 23 | 24 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dso_handle/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if DSO_DEF 4 | void* __dso_handle = NULL; 5 | #elif DSO_TENT 6 | void* __dso_handle; 7 | #else 8 | extern void* __dso_handle; 9 | #endif 10 | 11 | int main() 12 | { 13 | printf("dso_handle=%p\n", __dso_handle); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dtrace-static-probes-coalescing/Number.d: -------------------------------------------------------------------------------- 1 | provider Number { 2 | probe hit(int value); 3 | }; 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dtrace-static-probes-coalescing/a.cxx: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "header.h" 5 | 6 | 7 | void FUNC() { foo(); } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dtrace-static-probes-coalescing/header.h: -------------------------------------------------------------------------------- 1 | 2 | #include "Number.h" 3 | 4 | #define LOTS_O_PROBES { NUMBER_HIT(1); NUMBER_HIT(2); NUMBER_HIT(3); NUMBER_HIT(4); } 5 | 6 | 7 | inline void foo() { 8 | LOTS_O_PROBES 9 | } 10 | 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dtrace-static-probes-coalescing/x.cxx: -------------------------------------------------------------------------------- 1 | 2 | #include "header.h" 3 | 4 | void bar() { LOTS_O_PROBES } 5 | 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dtrace-static-probes/bar.d: -------------------------------------------------------------------------------- 1 | typedef int weirdType; 2 | 3 | provider Bar { 4 | probe count1(weirdType); 5 | }; 6 | 7 | #pragma D attributes Evolving/Evolving/Common provider Bar args 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dtrace-static-probes/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld can link a progam with dtrace static probes 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dtrace-static-probes/foo.d: -------------------------------------------------------------------------------- 1 | typedef int weirdType2; 2 | 3 | provider Foo { 4 | probe count1(weirdType2); 5 | }; 6 | 7 | 8 | #pragma D attributes Evolving/Evolving/Common provider Foo args 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/duplicate_symbols/duplicates.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void a() { 4 | } 5 | 6 | void b() { 7 | } 8 | 9 | void c() { 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/duplicate_symbols/main_extern.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file references an extern function c() that lives in 3 | a separate compilation unit that also has a() and b(). 4 | */ 5 | 6 | extern void c(); 7 | 8 | void a() { 9 | } 10 | 11 | void b() { 12 | } 13 | 14 | int main() { 15 | c(); 16 | } 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/duplicate_symbols/main_no_extern.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file contains symbols that are duplicated in another file, 3 | but does not reference anything that would pull in the duplicates. 4 | */ 5 | 6 | void a() { 7 | } 8 | 9 | void b() { 10 | } 11 | 12 | int main() { 13 | } 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-archive-all_load/bar.c: -------------------------------------------------------------------------------- 1 | void bar() {} 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-archive-all_load/baz.c: -------------------------------------------------------------------------------- 1 | void baz() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-archive-all_load/comment.txt: -------------------------------------------------------------------------------- 1 | Test that using -all_load to pull all .o files out of an archive 2 | proeduces good "debug notes". 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-archive-all_load/foo.c: -------------------------------------------------------------------------------- 1 | void foo() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-debug-notes-lto/header.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | inline int foo(int x) 4 | { 5 | return x + 10; 6 | } 7 | 8 | extern int bar(int x); -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-debug-notes-missing-directory/foo.c: -------------------------------------------------------------------------------- 1 | int foo() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-debug-notes-r/bar.cxx: -------------------------------------------------------------------------------- 1 | int bar() 2 | { 3 | return 10; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-debug-notes-r/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld 2 | produces good "debug notes" stabs from dwarf .o files after 3 | some of the .o files are merged with ld -r. 4 | Running nm through stabs-filter.pl produces connonical stabs 5 | that can be diffed against a checked in know good set of stabs 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-debug-notes-r/foo.cxx: -------------------------------------------------------------------------------- 1 | int foo() 2 | { 3 | return 10; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-debug-notes-r/main.cxx: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-debug-notes-uuid/main.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() 4 | { 5 | 6 | } 7 | 8 | 9 | void bar() 10 | { 11 | foo(); 12 | } 13 | 14 | 15 | 16 | int main() 17 | { 18 | bar(); 19 | return 0; 20 | } 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-debug-notes/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld 2 | produces good "debug notes" stabs from dwarf .o files 3 | Running nm through stabs-filter.pl produces connonical stabs 4 | that can be diffed against a checked in know good set of stabs 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-debug-notes/header.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | inline int foo(int x) 4 | { 5 | return x + 10; 6 | } 7 | 8 | extern int bar(int x); -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-debug-notes/hello.order: -------------------------------------------------------------------------------- 1 | 2 | # order __data section so even if different compiler lays out data 3 | # differently, linker lays out the same, so stabs are in same order 4 | .my_non_standard_name_static 5 | .my_non_standard_name 6 | __ZZ3bariE8bar_init 7 | _init 8 | _uninit 9 | __ZZ3bariE10bar_uninit 10 | __ZL7suninit 11 | __ZL5sinit 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-ignore/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld strips out the dwarf segment by default 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-strip-objc/hello.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main() 5 | { 6 | [NSString stringWithUTF8String: "hello"]; 7 | return 0; 8 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/dwarf-strip/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld -S produces no debug notes (stabs) 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dyld-fixup-chains/main.c: -------------------------------------------------------------------------------- 1 | int main() { for (;;);} 2 | int (*fptr)() = &main; 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib-aliases/bar.c: -------------------------------------------------------------------------------- 1 | void bar() { } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib-aliases/foo.c: -------------------------------------------------------------------------------- 1 | void foo() { } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib-aliases/main.c: -------------------------------------------------------------------------------- 1 | extern void foo(); 2 | extern void bar(); 3 | 4 | int main() { 5 | foo(); 6 | bar(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib-main/foo.c: -------------------------------------------------------------------------------- 1 | void foo() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib-main/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | fprintf(stdout, "hello\n"); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib-re-export-cycle/bar.c: -------------------------------------------------------------------------------- 1 | void bar() { } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib-re-export-cycle/foo.c: -------------------------------------------------------------------------------- 1 | void foo() { } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib-re-export-cycle/main.c: -------------------------------------------------------------------------------- 1 | extern void unfindable(); 2 | 3 | int main() { 4 | unfindable(); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib-upward/bar.c: -------------------------------------------------------------------------------- 1 | void bar() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib-upward/foo.c: -------------------------------------------------------------------------------- 1 | extern void bar(); 2 | 3 | void foo() 4 | { 5 | bar(); 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib_file-missing/bar.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | void bar() 5 | { 6 | } 7 | 8 | #if BAR_EXTRA 9 | void bar_extra() 10 | { 11 | } 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib_file-missing/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | 4 | void foo() 5 | { 6 | bar(); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib_file-missing/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | extern void bar(); 4 | extern void bar_extra(); 5 | 6 | int main() 7 | { 8 | foo(); 9 | bar(); 10 | #if BAR_EXTRA 11 | bar_extra(); 12 | #endif 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib_file/bar.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | void bar() 5 | { 6 | } 7 | 8 | #if BAR_EXTRA 9 | void bar_extra() 10 | { 11 | } 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib_file/comment.txt: -------------------------------------------------------------------------------- 1 | Verify that -dylib_file option allows you to replace an indirect dylib 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib_file/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | 4 | void foo() 5 | { 6 | bar(); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib_file/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | extern void bar(); 4 | extern void bar_extra(); 5 | 6 | int main() 7 | { 8 | foo(); 9 | bar(); 10 | #if BAR_EXTRA 11 | bar_extra(); 12 | #endif 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/dylib_init/foo.c: -------------------------------------------------------------------------------- 1 | void _init() { 2 | } 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/efi-basic/LibTest.c: -------------------------------------------------------------------------------- 1 | 2 | char *gS = (void *)0; 3 | 4 | void LibInit(void) 5 | { 6 | } 7 | 8 | 9 | void OutputString(char *String) 10 | { 11 | gS = String; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/eh-coalescing-no-labels/bar.c: -------------------------------------------------------------------------------- 1 | 2 | extern void other(); 3 | 4 | void bar() { 5 | other(); 6 | other(); 7 | } 8 | 9 | void __attribute__((weak)) my_weak() { 10 | other(); 11 | other(); 12 | } 13 | 14 | void bar2() { 15 | other(); 16 | other(); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /unit-tests/test-cases/eh-coalescing-no-labels/baz.c: -------------------------------------------------------------------------------- 1 | 2 | extern void other(); 3 | 4 | void baz() { 5 | other(); 6 | other(); 7 | } 8 | 9 | void __attribute__((weak)) my_weak() { 10 | other(); 11 | other(); 12 | } 13 | 14 | void baz2() { 15 | other(); 16 | other(); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /unit-tests/test-cases/eh-coalescing-no-labels/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern void other(); 3 | 4 | void foo() { 5 | other(); 6 | other(); 7 | } 8 | 9 | void __attribute__((weak)) my_weak() { 10 | other(); 11 | other(); 12 | } 13 | 14 | void foo2() { 15 | other(); 16 | other(); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /unit-tests/test-cases/eh-strip-test/main.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | std::vector stuff; 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/eh-stripped-symbols/keep.exp: -------------------------------------------------------------------------------- 1 | _main 2 | __Z3barv 3 | 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/empty-dylib/empty.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keith/ld64/7042a5f6bea71bc33c0a083911e03f86704f2e23/unit-tests/test-cases/empty-dylib/empty.c -------------------------------------------------------------------------------- /unit-tests/test-cases/empty-dylib/justdata.c: -------------------------------------------------------------------------------- 1 | int data = 1; 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/empty-object/main.c: -------------------------------------------------------------------------------- 1 | int main() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/end-label/bar.s: -------------------------------------------------------------------------------- 1 | 2 | .section __DATA,__other,regular 3 | 4 | .globl _next 5 | _next: 6 | nop 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/end-label/foo.s: -------------------------------------------------------------------------------- 1 | 2 | .data 3 | 4 | .globl _start 5 | .globl _end 6 | .globl _endAlias 7 | _start: 8 | .long 0 9 | .long 0 10 | _end: 11 | _endAlias: 12 | 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported-symbols-dead_strip/foo.exp: -------------------------------------------------------------------------------- 1 | _ABC 2 | _ABCD 3 | _DEF 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported-symbols-wildcards/expect1: -------------------------------------------------------------------------------- 1 | _foo2bar 2 | _foobar 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported-symbols-wildcards/expect2: -------------------------------------------------------------------------------- 1 | _fao 2 | _ffo 3 | _foo 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported-symbols-wildcards/expect3: -------------------------------------------------------------------------------- 1 | _foo 2 | _foo2 3 | _foo2bar 4 | _foobar 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported-symbols-wildcards/expect4: -------------------------------------------------------------------------------- 1 | _fao 2 | _ffo 3 | _foo 4 | _foo2 5 | _foo2bar 6 | _foobar 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported-symbols-wildcards/expect5: -------------------------------------------------------------------------------- 1 | _foo 2 | _foo2bar 3 | _foobar 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported-symbols-wildcards/expect6: -------------------------------------------------------------------------------- 1 | _fao 2 | _ffo 3 | _foo 4 | _foobar 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported-symbols-wildcards/expect7: -------------------------------------------------------------------------------- 1 | _fao 2 | _ffo 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported-symbols-wildcards/expect8: -------------------------------------------------------------------------------- 1 | _fao 2 | _ffo 3 | _foo 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported-symbols-wildcards/list5: -------------------------------------------------------------------------------- 1 | _foo 2 | _*bar 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported_symbols_list-eol/expected.nm: -------------------------------------------------------------------------------- 1 | _common_global2 2 | _func_global2 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported_symbols_list-eol/test.exp: -------------------------------------------------------------------------------- 1 | _func_global2 _common_global2 -------------------------------------------------------------------------------- /unit-tests/test-cases/exported_symbols_list-hidden/test.exp: -------------------------------------------------------------------------------- 1 | _func_global1 2 | _func_hidden1 3 | _common_global1 4 | _common_hidden1 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported_symbols_list-r/test-bad.exp: -------------------------------------------------------------------------------- 1 | _bar 2 | _baz 3 | _foobar 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/exported_symbols_list-r/test.exp: -------------------------------------------------------------------------------- 1 | _func_global2 2 | _common_global2 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/external-reloc-sorting/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int foo = 1; 3 | int bar = 2; 4 | int baz = 3; 5 | 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/fatal_warning/main.c: -------------------------------------------------------------------------------- 1 | 2 | int main() 3 | { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/filelist/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to check the two forms of the -filelist option 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/fixup-chains-page-overlap/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern void* arr[2]; 5 | 6 | int main() { 7 | printf("main: %p, arr[0]: %p, arr[1]: %p\n", &main, arr[0], arr[1]); 8 | assert(&main == arr[1]); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/fixup-chains-page-overlap/page_overlap_align.s: -------------------------------------------------------------------------------- 1 | .section __TEXT,__text,regular,pure_instructions 2 | .section __DATA_CONST,__data 3 | .p2align 14 4 | 5 | // place _arr right before the end of the page, so there's a pointer fixup at a 6 | // page boundary location _arr+8 7 | .zero 16384 - 12 8 | 9 | .global _arr 10 | _arr: 11 | .zero 8 12 | .quad _main 13 | 14 | .subsections_via_symbols 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/flat-indirect-undefines/bar.c: -------------------------------------------------------------------------------- 1 | 2 | void bar() {} 3 | 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/flat-indirect-undefines/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | 4 | void foo() 5 | { 6 | bar(); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/flat-indirect-undefines/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void foo(); 4 | 5 | 6 | int main() 7 | { 8 | foo(); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/force-weak/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int foo = 5; -------------------------------------------------------------------------------- /unit-tests/test-cases/force-weak/test.c: -------------------------------------------------------------------------------- 1 | 2 | extern int foo; 3 | 4 | int getfoo() { return foo; } 5 | 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/force-weak/weak.exp: -------------------------------------------------------------------------------- 1 | _foo 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/function-starts/main.c: -------------------------------------------------------------------------------- 1 | 2 | void foo() {} 3 | 4 | void mid() {} 5 | 6 | static void bar() { foo(); } 7 | 8 | int main() { bar(); return 0; } 9 | 10 | 11 | #if __STATIC__ 12 | void myexit() {} 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/header-pad/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld can link a hello-world program with no errors (or crashes) 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/hello-world/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld can link a hello-world program with no errors (or crashes) 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/hidden-r/foo.c: -------------------------------------------------------------------------------- 1 | void __attribute__((weak,visibility("hidden"))) my_weak() 2 | { 3 | } 4 | 5 | int __attribute__((visibility("hidden"))) my_tent; 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/hidden-r/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void my_weak(); 4 | extern int my_tent; 5 | 6 | int main() 7 | { 8 | my_tent = 0; 9 | my_weak(); 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/image_suffix/bar.c: -------------------------------------------------------------------------------- 1 | void bar() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/image_suffix/foo.c: -------------------------------------------------------------------------------- 1 | extern void bar(); 2 | 3 | void foo() 4 | { 5 | bar(); 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/implicit-common2/a.c: -------------------------------------------------------------------------------- 1 | extern int common_variable; 2 | 3 | int 4 | main(int argc, char **argv) 5 | { 6 | return common_variable; 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/implicit-common2/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld can link a program with a large zero-fill section 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/implicit-common4/a.c: -------------------------------------------------------------------------------- 1 | extern int common_variable; 2 | 3 | int 4 | main(int argc, char **argv) 5 | { 6 | return common_variable; 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/implicit-common4/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld can link a program with a large zero-fill section 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/implicit-common5/a.c: -------------------------------------------------------------------------------- 1 | extern int common_variable; 2 | 3 | int 4 | main(int argc, char **argv) 5 | { 6 | return common_variable; 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/implicit-common5/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld can link a program with a large zero-fill section 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/implicit_dylib/bar.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | void bar() 5 | { 6 | } 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/implicit_dylib/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/implicit_dylib/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | extern void bar(); 4 | 5 | int main() 6 | { 7 | foo(); 8 | bar(); 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/indirect-dylib/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that an indirect 2 | library is not accidentally searched for symbols. 3 | 4 | wrong error message when symbol is found in unused indirect library# 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/indirect-path-search/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/indirect-path-search/baz.c: -------------------------------------------------------------------------------- 1 | 2 | int baz (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/indirect-path-search/foo.c: -------------------------------------------------------------------------------- 1 | int foo (void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/indirect-path-search/main.c: -------------------------------------------------------------------------------- 1 | extern int foo (); 2 | extern int bar (); 3 | extern int baz (); 4 | 5 | int main (void) 6 | { 7 | return foo() + bar() + baz(); 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/init-order/bar.cxx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class Bar { 5 | public: 6 | Bar() : a(20) {} 7 | ~Bar() {} 8 | private: 9 | int a; 10 | }; 11 | 12 | 13 | Bar b1; 14 | Bar b2; 15 | 16 | 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/init-order/foo.cxx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class Foo { 5 | public: 6 | Foo() : a(20) {} 7 | ~Foo() {} 8 | private: 9 | int a; 10 | }; 11 | 12 | 13 | Foo f1; 14 | Foo f2; 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/init-order/main.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class M { 4 | public: 5 | M() : a(20) {} 6 | ~M() {} 7 | private: 8 | int a; 9 | }; 10 | 11 | 12 | M m1; 13 | M m2; 14 | 15 | int main() 16 | { 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /unit-tests/test-cases/install-name-override/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern int foo(); 3 | 4 | int main() 5 | { 6 | foo(); 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/interposable_list/test.exp: -------------------------------------------------------------------------------- 1 | _test1 2 | _test2 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/kext-fixup-chains/main.c: -------------------------------------------------------------------------------- 1 | int main() { for (;;);} 2 | int (*fptr)() = &main; 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/kext-undefined-export/mykext-i386.exp: -------------------------------------------------------------------------------- 1 | _kmod_info 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/kext-undefined-export/mykext.exp: -------------------------------------------------------------------------------- 1 | _kmod_info 2 | _foo 3 | _my_used_external_global 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/label-on-end-of-section-order/foo.s: -------------------------------------------------------------------------------- 1 | .lcomm _mybss ,4, 2 2 | 3 | .text 4 | .align 4 5 | .globl _main 6 | _main: 7 | #if __x86_64__ 8 | movl $0, _mybss(%rip) 9 | #elif __i386__ 10 | movl $0, _mybss 11 | #elif __arm__ 12 | .long _mybss 13 | #endif 14 | 15 | .section __DATA, _stuff 16 | .align 4 17 | _start_stuff: 18 | .long 0x0 19 | .long 0x0 20 | _end_stuff: 21 | 22 | 23 | .subsections_via_symbols 24 | -------------------------------------------------------------------------------- /unit-tests/test-cases/label-on-end-of-section/foo.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .section __MY, __data 4 | _start: 5 | .long 0 6 | _end: 7 | 8 | # _var is a pointer to the end of the __MY/__data section 9 | .data 10 | _var: 11 | #if __x86_64__ 12 | .quad _end 13 | #else 14 | .long _end 15 | #endif 16 | 17 | .subsections_via_symbols -------------------------------------------------------------------------------- /unit-tests/test-cases/late-link-error/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that if 2 | ld errors out during linking, that no output file is remaining 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lazy-dylib-objc/foo.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | 5 | @interface Foo : NSObject 6 | 7 | 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lazy-dylib-objc/foo.m: -------------------------------------------------------------------------------- 1 | 2 | #include "foo.h" 3 | 4 | @implementation Foo 5 | 6 | 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lazy-dylib-objc/main.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "foo.h" 5 | 6 | 7 | int main() 8 | { 9 | [[Foo alloc] init]; 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lazy-dylib/bad.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | extern int data; 6 | 7 | static int* pd = &data; 8 | 9 | int main() 10 | { 11 | return *pd; 12 | } 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lazy-dylib/bad2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | extern int foo(); 6 | 7 | int main() 8 | { 9 | int (*func)() = foo; 10 | if ( func != NULL ) 11 | (*func)(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lazy-dylib/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int data = 5; 3 | 4 | int foo() { return 1; } 5 | int bar() { return 1; } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lazy-dylib/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | extern int foo(); 6 | extern int bar(); 7 | 8 | int main() 9 | { 10 | // two regular external function calls 11 | void* x = malloc(16); 12 | free(x); 13 | // two lazy dylib external function calls 14 | int result = foo(); 15 | fprintf(stderr, "foo() returned %d\n", result); 16 | bar(); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker-optimization-hints/main.s: -------------------------------------------------------------------------------- 1 | 2 | .text 3 | .align 2 4 | .globl _main 5 | _main: ret lr 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-framework-static-chain/bar.c: -------------------------------------------------------------------------------- 1 | void bar() { } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-framework-static-chain/baz.c: -------------------------------------------------------------------------------- 1 | void baz() { } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-framework-static-chain/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | extern void baz(); 4 | 5 | void foo() { 6 | bar(); 7 | baz(); 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-framework-static-chain/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | 4 | int main() 5 | { 6 | foo(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-framework-static/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() { } 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-framework-static/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | 4 | int main() 5 | { 6 | foo(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-framework/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() { } 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-framework/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | 4 | int main() 5 | { 6 | foo(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-library-chain/bar.c: -------------------------------------------------------------------------------- 1 | void bar() { } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-library-chain/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | extern void subbar(); 4 | 5 | void foo() { 6 | bar(); 7 | subbar(); 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-library-chain/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | 4 | int main() 5 | { 6 | foo(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-library-chain/subbar.c: -------------------------------------------------------------------------------- 1 | void subbar() { } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-library/bar.c: -------------------------------------------------------------------------------- 1 | void bar() { } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-library/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() { } 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-library/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | extern void bar(); 4 | 5 | int main() 6 | { 7 | foo(); 8 | bar(); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-needed-library/foo.c: -------------------------------------------------------------------------------- 1 | void foo() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/linker_options-needed-library/main.c: -------------------------------------------------------------------------------- 1 | int main() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/literals-coalesce-alignment2/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to verify that when two cstrings are coalesced that the one with greater alignment is used. 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/literals-coalesce-alignment3/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to verify that when two cstrings are coalesced that the one with greater alignment is used. 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/literals-coalesce2/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to verify that literals are uniqued. After running ld -r all duplicates should be removed. 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/literals-coalesce2/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SZ=`size "$1" | tail -n 1 | sed 's,\([0-9]*\).*,\1,'` 4 | [ "$SZ" ] && [ "$SZ" = 54 ] && exit 0 5 | exit 1 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a.c: -------------------------------------------------------------------------------- 1 | int foo3() 2 | { 3 | return 21; 4 | } 5 | 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | extern int foo4(); 5 | int foo3() 6 | { 7 | /* printf ("%s\n",strerror(errno)); */ 8 | return foo4(); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a10.c: -------------------------------------------------------------------------------- 1 | extern void foo(void); 2 | 3 | void foo(void) 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a11.c: -------------------------------------------------------------------------------- 1 | #include 2 | void foo3(void) 3 | { 4 | fputc ('x', stderr); 5 | printf ("\n"); 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a12.c: -------------------------------------------------------------------------------- 1 | #include "a12.h" 2 | 3 | enum E e[1000]; 4 | void foo(void) 5 | { 6 | e[1] = ONE; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a12.h: -------------------------------------------------------------------------------- 1 | enum E 2 | { 3 | ZERO, 4 | ONE 5 | }; 6 | 7 | extern enum E e[1000]; 8 | extern void foo(void); 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a13.cc: -------------------------------------------------------------------------------- 1 | #include "a13.h" 2 | 3 | A::~A() {} 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a13.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class A { 4 | public: 5 | virtual ~A(); 6 | void foo() { printf ("Hi\n"); } 7 | }; 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a14.c: -------------------------------------------------------------------------------- 1 | int X __attribute__((visibility("hidden"))) = 14; 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a15.c: -------------------------------------------------------------------------------- 1 | void __attribute__((visibility("hidden"))) foo() 2 | { 3 | } 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a17.c: -------------------------------------------------------------------------------- 1 | 2 | int a = 0; 3 | int func_a() { return a; } 4 | 5 | // add code that will cause stack canary 6 | extern void fill(char*); 7 | void test() 8 | { 9 | char buf[100]; 10 | fill(buf); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a2.c: -------------------------------------------------------------------------------- 1 | extern int foo4(void); 2 | int foo3() 3 | { 4 | return foo4(); 5 | } 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a20.c: -------------------------------------------------------------------------------- 1 | void foo() {} 2 | void bar() {} 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a3.c: -------------------------------------------------------------------------------- 1 | int bar; 2 | int foo1() 3 | { 4 | return bar; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a4.c: -------------------------------------------------------------------------------- 1 | extern int foo4(void); 2 | int foo3() 3 | { 4 | return foo4(); 5 | } 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a5.c: -------------------------------------------------------------------------------- 1 | extern int foo2(void); 2 | extern int foo3(void); 3 | 4 | int foo1() 5 | { 6 | int i = 42; 7 | if (foo2()) 8 | i = foo3(); 9 | return i; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a6.c: -------------------------------------------------------------------------------- 1 | 2 | int foo1() 3 | { 4 | return 42; 5 | } 6 | 7 | int foo2() 8 | { 9 | return 21; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a7.c: -------------------------------------------------------------------------------- 1 | extern int foo3(void); 2 | 3 | int foo1(void) 4 | { 5 | return foo3(); 6 | } 7 | 8 | int foo2(void) 9 | { 10 | return 42; 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a8.c: -------------------------------------------------------------------------------- 1 | 2 | static signed int i = 0; 3 | extern int foo1(void); 4 | extern void foo2(void); 5 | 6 | void foo2(void) { 7 | 8 | i = -1; 9 | 10 | } 11 | 12 | static int foo3() { 13 | return 10; 14 | } 15 | 16 | int foo1(void) 17 | { 18 | int data = 0; 19 | if (i < 0) 20 | data = foo3(); 21 | data += 42; 22 | return data; 23 | } 24 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a9.c: -------------------------------------------------------------------------------- 1 | 2 | static signed int i = 0; 3 | extern int foo1(void); 4 | extern void foo2(void); 5 | extern void foo4(void); 6 | 7 | void foo2(void) { 8 | 9 | i = -1; 10 | 11 | } 12 | 13 | static int foo3() { 14 | foo4(); 15 | return 10; 16 | } 17 | 18 | int foo1(void) 19 | { 20 | int data = 0; 21 | if (i < 0) 22 | data = foo3(); 23 | data += 42; 24 | return data; 25 | } 26 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/a9.list: -------------------------------------------------------------------------------- 1 | _foo1 2 | _main 3 | _bar 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b.c: -------------------------------------------------------------------------------- 1 | int foo2() { 2 | return 21; 3 | } 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b1.c: -------------------------------------------------------------------------------- 1 | extern int foo4(); 2 | int foo2() { 3 | return foo4(); 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b10.c: -------------------------------------------------------------------------------- 1 | #include "b10.h" 2 | extern void foo(void); 3 | 4 | struct my_struct my_hooks = { 5 | foo 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b10.h: -------------------------------------------------------------------------------- 1 | struct my_struct 2 | { 3 | void (*f)(void); 4 | }; 5 | 6 | extern struct my_struct my_hooks; 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b14.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int Y; 4 | extern int X __attribute__((visibility("hidden"))); 5 | void foo() { 6 | printf ("%d\n", X); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b15.c: -------------------------------------------------------------------------------- 1 | extern void foo(); 2 | void bar() { 3 | foo(); 4 | } 5 | 6 | void __attribute__((visibility("hidden"))) f2() 7 | {} 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b17.c: -------------------------------------------------------------------------------- 1 | int b = 0; 2 | int func_b() { return b; } 3 | 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b2.c: -------------------------------------------------------------------------------- 1 | extern int foo4(void); 2 | 3 | int foo4(void) 4 | { 5 | return 21; 6 | } 7 | int foo2() { 8 | return foo4(); 9 | } 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b20.c: -------------------------------------------------------------------------------- 1 | void frob() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b3.c: -------------------------------------------------------------------------------- 1 | extern int bar; 2 | int foo2() { 3 | return bar; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b4.c: -------------------------------------------------------------------------------- 1 | extern int foo4(void); 2 | 3 | int foo4(void) 4 | { 5 | return 21; 6 | } 7 | static int myfoo() 8 | { 9 | return foo4(); 10 | } 11 | int foo2() { 12 | return myfoo(); 13 | } 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b5.c: -------------------------------------------------------------------------------- 1 | int foo2(void) 2 | { 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/b7.c: -------------------------------------------------------------------------------- 1 | extern int foo2(void); 2 | extern int foo3(void); 3 | 4 | int foo3(void) 5 | { 6 | return foo2(); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/c15.c: -------------------------------------------------------------------------------- 1 | extern void foo(); 2 | int main() { 3 | foo(); 4 | return 0; 5 | } 6 | 7 | void __attribute__((visibility("hidden"))) f2() 8 | { 9 | } 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main.c: -------------------------------------------------------------------------------- 1 | extern int foo2(); 2 | extern int foo3(); 3 | int main(){ 4 | int i = foo3() + foo2(); 5 | if (i == 42) 6 | return 0; 7 | else 8 | return 1; 9 | } 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main1.c: -------------------------------------------------------------------------------- 1 | extern int foo2(); 2 | extern int foo3(); 3 | int foo4() 4 | { 5 | return 21; 6 | } 7 | int main(){ 8 | int i = foo3() + foo2(); 9 | if (i == 42) 10 | return 0; 11 | else 12 | return 1; 13 | } 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main10.c: -------------------------------------------------------------------------------- 1 | #include "b10.h" 2 | 3 | int main() 4 | { 5 | struct my_struct *mh = &my_hooks; 6 | 7 | mh->f(); 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main11.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo3(void); 3 | int main() 4 | { 5 | foo3(); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main12.c: -------------------------------------------------------------------------------- 1 | #include "a12.h" 2 | int main() 3 | { 4 | e[0] = ZERO; 5 | foo(); 6 | return e[0]; 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main13.cc: -------------------------------------------------------------------------------- 1 | #include "a13.h" 2 | 3 | int main() 4 | { 5 | A a; 6 | a.foo(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main16.c: -------------------------------------------------------------------------------- 1 | 2 | int tent; 3 | int global = 5; 4 | 5 | int foo() { return tent + global; } 6 | 7 | int main() { foo(); return 0; } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main19.c: -------------------------------------------------------------------------------- 1 | extern int foo(); 2 | 3 | int main() 4 | { 5 | foo(); 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main2.c: -------------------------------------------------------------------------------- 1 | extern int foo2(); 2 | extern int foo3(); 3 | int main(){ 4 | int i = foo3() + foo2(); 5 | if (i == 42) 6 | return 0; 7 | else 8 | return 1; 9 | } 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main20.c: -------------------------------------------------------------------------------- 1 | extern void foo(); 2 | 3 | int main() 4 | { 5 | foo(); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main3.c: -------------------------------------------------------------------------------- 1 | extern int foo1(); 2 | extern int foo2(); 3 | extern int bar; 4 | int main(){ 5 | int i; 6 | bar = 14; 7 | i = foo1() + foo2() + bar; 8 | if (i == 42) 9 | return 0; 10 | else 11 | return 1; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main4.c: -------------------------------------------------------------------------------- 1 | extern int foo2(); 2 | extern int foo3(); 3 | int main(){ 4 | int i = foo3() + foo2(); 5 | if (i == 42) 6 | return 0; 7 | else 8 | return 1; 9 | } 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main5.c: -------------------------------------------------------------------------------- 1 | 2 | extern int foo1(void); 3 | 4 | int foo3(void) 5 | { 6 | return 42; 7 | } 8 | 9 | int main() 10 | { 11 | int i = foo1(); 12 | if (i == 42) 13 | return 0; 14 | else 15 | return 1; 16 | } 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main6.c: -------------------------------------------------------------------------------- 1 | extern int foo1(); 2 | 3 | int main() 4 | { 5 | int i = foo1(); 6 | if (i == 42) 7 | return 0; 8 | else 9 | return 1; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main7.c: -------------------------------------------------------------------------------- 1 | extern int foo1(void); 2 | 3 | int main(void) 4 | { 5 | int i = foo1(); 6 | if (i == 42) 7 | return 0; 8 | else 9 | return 1; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main8.c: -------------------------------------------------------------------------------- 1 | extern int foo1(void); 2 | extern void foo2(void); 3 | 4 | int main() 5 | { 6 | int i = foo1(); 7 | if (i == 42) 8 | return 0; 9 | else 10 | return 1; 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/llvm-integration/main9.c: -------------------------------------------------------------------------------- 1 | extern int foo1(void); 2 | extern void foo2(void); 3 | 4 | void foo4(void) 5 | { 6 | } 7 | int main() 8 | { 9 | int i = foo1(); 10 | if (i == 42) 11 | return 0; 12 | else 13 | return 1; 14 | } 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/loader_path/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar() 3 | { 4 | return 1; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/loader_path/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern int bar(); 3 | 4 | int foo() 5 | { 6 | return bar(); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/loader_path/main.c: -------------------------------------------------------------------------------- 1 | extern void foo(); 2 | 3 | int main() 4 | { 5 | foo(); 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/local-symbol-partial-stripping/a.expect: -------------------------------------------------------------------------------- 1 | < _myglobal 2 | < _xmyglobal2 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/local-symbol-partial-stripping/a.list: -------------------------------------------------------------------------------- 1 | _myglobal 2 | _xmyglobal2 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/local-symbol-partial-stripping/b.expect: -------------------------------------------------------------------------------- 1 | < _myfunction 2 | < _myglobal2 3 | < _xmyglobal2 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/local-symbol-partial-stripping/b.list: -------------------------------------------------------------------------------- 1 | *2 2 | _myf*on 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/local-symbol-partial-stripping/c.list: -------------------------------------------------------------------------------- 1 | *my* 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/local-symbol-partial-stripping/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int __attribute__((visibility("hidden"))) myglobal = 3; 4 | int __attribute__((visibility("hidden"))) myglobal2 = 3; 5 | int __attribute__((visibility("hidden"))) xmyglobal = 3; 6 | int __attribute__((visibility("hidden"))) xmyglobal2 = 3; 7 | 8 | void __attribute__((visibility("hidden"))) myfunction(int x) { } 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/local-symbol-partial-stripping/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern int myglobal; 4 | extern void myfunction(int); 5 | 6 | int main() 7 | { 8 | myfunction(myglobal); 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-archive-dylib/foo.c: -------------------------------------------------------------------------------- 1 | #include 2 | void foo() 3 | { 4 | fprintf(stderr, "hello\n"); 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-archive-dylib/main.c: -------------------------------------------------------------------------------- 1 | extern void foo(); 2 | 3 | int main() 4 | { 5 | foo(); 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-archive-objc/bar.m: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | @interface Bar : NSObject 5 | @end 6 | 7 | @implementation Bar 8 | @end 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-archive-objc/baz.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface NSObject(MyCategory) 4 | - (void) doit; 5 | @end 6 | 7 | @implementation NSObject(MyCategory) 8 | - (void) doit 9 | { 10 | } 11 | @end 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-archive-objc/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern void neverFindMe(); 3 | 4 | __attribute__((constructor)) 5 | void myinit() 6 | { 7 | neverFindMe(); 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-archive-objc/main.c: -------------------------------------------------------------------------------- 1 | 2 | int main() 3 | { 4 | return 0; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dead_strip-all-hidden/bar.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void bar() {} 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dead_strip-coalesce/foo.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | void foo1() 6 | { 7 | CFStringGetLength(CFSTR("test1")); 8 | strlen("str1"); 9 | } 10 | 11 | void foo2() 12 | { 13 | CFStringGetLength(CFSTR("test2")); 14 | strlen("str2"); 15 | } 16 | 17 | void foo3() 18 | { 19 | CFStringGetLength(CFSTR("test3")); 20 | strlen("str3"); 21 | } 22 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dead_strip-inline-asm/bar.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void qux() {} 4 | 5 | asm("\t.text\n" 6 | "\t.globl _foo\n" 7 | "_foo:\n" 8 | "\tnop\n"); 9 | 10 | extern void foo(); 11 | 12 | void (*bar())() { 13 | return foo; 14 | } 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dead_strip-some-hidden/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int data[] = { 4, 5, 6 }; 3 | int deaddata[] = { 7, 8, 9 }; 4 | 5 | int func() { return 0; } 6 | int deadfunc() { return 0; } 7 | 8 | __attribute__((visibility("default"))) 9 | int* foo() 10 | { 11 | return data; 12 | } 13 | 14 | __attribute__((visibility("default"))) 15 | void* foo2() 16 | { 17 | return func; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dead_strip-tentative/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int tent; 3 | 4 | int bar() { return tent; } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dead_strip-tentative/baz.c: -------------------------------------------------------------------------------- 1 | 2 | int tent; 3 | 4 | int baz() { return tent; } 5 | 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dead_strip-tentative/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int tent; 3 | 4 | int foo() { return tent; } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dead_strip-tentative/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern int foo(); 3 | extern int bar(); 4 | extern int baz(); 5 | 6 | int main() 7 | { 8 | foo(); 9 | bar(); 10 | baz(); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dead_strip-unused/bar.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void bar() 4 | { 5 | } 6 | 7 | 8 | extern void unused1(); 9 | 10 | void unused2() 11 | { 12 | unused1(); 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dead_strip-unused/main.c: -------------------------------------------------------------------------------- 1 | extern void bar(); 2 | 3 | int main() 4 | { 5 | bar(); 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-duplicate_symbols/main.c: -------------------------------------------------------------------------------- 1 | int same_name(); 2 | int other(); 3 | 4 | int main(void) 5 | { 6 | return same_name() + other(); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-duplicate_symbols/non-static.c: -------------------------------------------------------------------------------- 1 | int same_name(void) 2 | { 3 | return 32; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-duplicate_symbols/static.c: -------------------------------------------------------------------------------- 1 | static int same_name(int i) 2 | { 3 | return i + 10; 4 | } 5 | 6 | int other() 7 | { 8 | return same_name(100); 9 | } 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dylib-aliases/foo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | void foo() { 5 | printf("hello\n"); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dylib-export_list/bar.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | #include "foo.h" 3 | 4 | static void bar1() {} 5 | 6 | void bar_test() { 7 | printf("%p\n", &bar1); 8 | printf("%p\n", &Foo::doit); 9 | printf("%p\n", &Foo::doit2); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dylib-export_list/foo.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | #include "foo.h" 3 | 4 | static void foo1() {} 5 | 6 | void foo_test() { 7 | printf("%p\n", &foo1); 8 | printf("%p\n", &Foo::doit); 9 | printf("%p\n", &Foo::doit2); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dylib-export_list/foo.exp: -------------------------------------------------------------------------------- 1 | __Z8bar_testv 2 | __Z8foo_testv 3 | 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dylib-export_list/foo.h: -------------------------------------------------------------------------------- 1 | 2 | class Foo { 3 | public: 4 | static void doit() { } 5 | static void doit2() { } 6 | }; 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-dynamic_export/main.c: -------------------------------------------------------------------------------- 1 | 2 | __attribute__((visibility("hidden"))) 3 | void foo() { } 4 | 5 | void bar() { } 6 | 7 | 8 | int main() 9 | { 10 | foo(); 11 | bar(); 12 | 13 | return 0; 14 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-llvm-options/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | 5 | void foo(int x) 6 | { 7 | printf("hello, world %d\n", x); 8 | } 9 | 10 | int main() 11 | { 12 | foo(10); 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-objc-archive/bar.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Bar : NSObject 4 | @end 5 | 6 | extern void bar2(); 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-objc-archive/bar.m: -------------------------------------------------------------------------------- 1 | #include "bar.h" 2 | 3 | @implementation Bar 4 | - (void) test { 5 | bar2(); 6 | } 7 | @end 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-objc-archive/bar2.c: -------------------------------------------------------------------------------- 1 | 2 | void bar2() {} 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-objc-archive/foo.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | @end 5 | 6 | 7 | extern void foo2(); 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-objc-archive/foo.m: -------------------------------------------------------------------------------- 1 | 2 | #include "foo.h" 3 | 4 | @implementation Foo 5 | - (void) test { 6 | foo2(); 7 | } 8 | @end 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-objc-archive/foo2.c: -------------------------------------------------------------------------------- 1 | 2 | void foo2() {} 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-objc-archive/main.m: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "foo.h" 4 | #include "bar.h" 5 | 6 | 7 | @interface FooSubClass : Foo 8 | @end 9 | 10 | 11 | @implementation FooSubClass 12 | @end 13 | 14 | 15 | int main() 16 | { 17 | [Bar alloc]; 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-objc-image-info/main.m: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main() { 5 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 6 | [pool drain]; 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-object_path/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | 5 | void foo(int x) 6 | { 7 | printf("hello, world %d\n", x); 8 | } 9 | 10 | int main() 11 | { 12 | foo(10); 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-preload-pie/a.c: -------------------------------------------------------------------------------- 1 | 2 | extern const char* mystring; 3 | 4 | const char** myp = &mystring; 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-preload-pie/b.c: -------------------------------------------------------------------------------- 1 | const char* mystring = "hello"; 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-preload-pie/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern const char** myp; 3 | 4 | 5 | const char** entry(int i) { 6 | if ( i ) { 7 | *myp = "help"; 8 | } 9 | return myp; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-r/bar.c: -------------------------------------------------------------------------------- 1 | void bar() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-r/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | 5 | void foo(int x) 6 | { 7 | printf("hello, world %d\n", x); 8 | } 9 | 10 | int main() 11 | { 12 | foo(10); 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-rename_section/a.c: -------------------------------------------------------------------------------- 1 | 2 | extern const char* mystring; 3 | 4 | const char** myp = &mystring; 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-rename_section/b.c: -------------------------------------------------------------------------------- 1 | const char* mystring = "hello"; 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-rename_section/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern const char** myp; 3 | 4 | 5 | const char** entry(int i) { 6 | if ( i ) { 7 | *myp = "help"; 8 | } 9 | return myp; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-rename_segment/a.c: -------------------------------------------------------------------------------- 1 | 2 | extern const char* mystring; 3 | 4 | const char** myp = &mystring; 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-rename_segment/b.c: -------------------------------------------------------------------------------- 1 | const char* mystring = "hello"; 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-rename_segment/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern const char** myp; 3 | extern const char* mystring; 4 | 5 | 6 | __attribute__((section("__DATA,__data_extra"))) 7 | int param = 0; 8 | 9 | 10 | const char** entry(int i) { 11 | if ( i ) { 12 | *myp = "help"; 13 | } 14 | param = i; 15 | return myp; 16 | } 17 | 18 | int get() { return param; } -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-static-pie/a.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int a_value = 10; 4 | 5 | int a(const char* l, const char* r) 6 | { 7 | a_value = *l; 8 | return (*l == *r); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-static-pie/b.c: -------------------------------------------------------------------------------- 1 | const char* b = "hello"; 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-static-pie/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern int a(const char*, const char*); 3 | extern char* b; 4 | extern int a_value; 5 | 6 | int entry(const char* param) { 7 | if ( a(param, b) ) { 8 | return a_value + 10; 9 | } 10 | return a_value; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-symbol-section-move/other.c: -------------------------------------------------------------------------------- 1 | 2 | static int mylocal() 3 | { 4 | return 1; 5 | } 6 | 7 | void* otherget() { return mylocal; } 8 | 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-symbol-section-move/ram1.symbols: -------------------------------------------------------------------------------- 1 | main.o:* 2 | _abc 3 | _com4 4 | 5 | 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-symbol-section-move/rom1.symbols: -------------------------------------------------------------------------------- 1 | foo.o:* 2 | _mainget 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-thin-mixed-weak-defs/bar.cpp: -------------------------------------------------------------------------------- 1 | #include "foo_impl.h" 2 | 3 | int bar() { 4 | return foo_impl(); 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-thin-mixed-weak-defs/foo.cpp: -------------------------------------------------------------------------------- 1 | #include "foo_impl.h" 2 | 3 | int foo() { 4 | return foo_impl(); 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-thin-mixed-weak-defs/foo_impl.h: -------------------------------------------------------------------------------- 1 | template 2 | struct foo_impl { 3 | 4 | foo_impl() {} 5 | 6 | operator T() const { return 0; } 7 | }; 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-thin-mixed-weak-defs/main.cpp: -------------------------------------------------------------------------------- 1 | #include "foo_impl.h" 2 | 3 | int foo_dummy() { 4 | return foo_impl(); 5 | } 6 | 7 | int foo(); 8 | 9 | int main() { 10 | return foo(); 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-unexport-sym/a.c: -------------------------------------------------------------------------------- 1 | void foo(); 2 | void bar() { 3 | foo(); 4 | } 5 | 6 | int main() { 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-unexport-sym/b.c: -------------------------------------------------------------------------------- 1 | void foo() { 2 | 3 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-unexport-sym/unexp.list: -------------------------------------------------------------------------------- 1 | _foo 2 | _bar 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-weak-native-override/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() 4 | { 5 | // do nothing 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-weak-native-override/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | static void die() { abort(); } 5 | 6 | 7 | __attribute__((visibility("hidden"),weak)) void foo() 8 | { 9 | die(); 10 | } 11 | 12 | int main() 13 | { 14 | foo(); 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-weak_import/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() {} 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/lto-weak_import/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | extern void foo() __attribute__((weak_import)); 5 | 6 | 7 | int main() 8 | { 9 | if ( &foo != NULL ) 10 | foo(); 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/main-stripped/main.exp: -------------------------------------------------------------------------------- 1 | _main 2 | _magicSymbol 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/missing-option-args/comment.txt: -------------------------------------------------------------------------------- 1 | Verify that missing arguments don't cause ld to crash 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/multiple-entry-points/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to verify a .o file can round-trip through ld -r correctly. The ObjectDump utility is used 2 | dump a "canonical" textual representation of a .o file. The before and after .o files are then diff'ed. 3 | No differences means this test passes 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/no-data-bundle/foo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void foo() 4 | { 5 | rand(); 6 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/no-dynamic-common/a.c: -------------------------------------------------------------------------------- 1 | extern int common_variable; 2 | 3 | int 4 | main(int argc, char **argv) 5 | { 6 | return common_variable; 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/no-dynamic-common/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to determine if common symbols are not allowed with MH_DYLIB output format with the -multi_module option 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/no-object-symbols/empty.s: -------------------------------------------------------------------------------- 1 | 2 | .text 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/no-uuid/bar.c: -------------------------------------------------------------------------------- 1 | int bar (void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/no-uuid/comment.txt: -------------------------------------------------------------------------------- 1 | Test the we set emit LC_UUID correctly 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/no-uuid/foo.c: -------------------------------------------------------------------------------- 1 | int main (void) 2 | { 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/non-lazy-r/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | extern int foo; 5 | 6 | int getfoo() { return foo; } 7 | 8 | 9 | extern int other; 10 | 11 | int getother() { return other; } 12 | 13 | 14 | extern int tent; 15 | 16 | int gettent() { return tent; } 17 | 18 | 19 | extern void* func; 20 | void* getfunc() { return func; } 21 | -------------------------------------------------------------------------------- /unit-tests/test-cases/non-lazy-r/other.c: -------------------------------------------------------------------------------- 1 | int foo = 2; 2 | int other = 3; 3 | int tent; 4 | void func() {} 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-abi/test.m: -------------------------------------------------------------------------------- 1 | 2 | @interface Foo 3 | @end 4 | 5 | @implementation Foo 6 | @end 7 | 8 | 9 | int main() 10 | { 11 | return 0; 12 | } 13 | 14 | 15 | #if __i386__ && __OBJC2__ 16 | int _objc_empty_vtable = 1; 17 | #endif 18 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-category-archive/main.m: -------------------------------------------------------------------------------- 1 | 2 | int main() 3 | { 4 | return 0; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-category-archive/test2.m: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | @interface MyClass : NSObject 5 | - (void) mymethod2; 6 | @end 7 | 8 | @implementation MyClass 9 | - (void) mymethod2 { } 10 | @end 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-category-class-property-mismatch/class.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | @end 5 | 6 | 7 | @implementation Foo 8 | @end 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-category-optimize-external/foo.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | #ifndef NO_BASE_METHODS 5 | -(void) instance_method; 6 | +(void) class_method; 7 | #endif 8 | @end 9 | 10 | 11 | @implementation Foo 12 | #ifndef NO_BASE_METHODS 13 | -(void) instance_method {} 14 | +(void) class_method {} 15 | #endif 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-category-optimize-load/cat1.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | -(void) method1; 5 | @end 6 | 7 | 8 | @interface Foo(mycat) 9 | +(void) load; 10 | @end 11 | 12 | @implementation Foo(mycat) 13 | +(void) load {} 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-category-optimize-load/foo.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | @end 5 | 6 | 7 | @implementation Foo 8 | @end 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-category-optimize/foo.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | #ifndef NO_BASE_METHODS 5 | -(void) instance_method; 6 | +(void) class_method; 7 | #endif 8 | @end 9 | 10 | 11 | @implementation Foo 12 | #ifndef NO_BASE_METHODS 13 | -(void) instance_method {} 14 | +(void) class_method {} 15 | #endif 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-category-warning/copycat.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | -(void) method1; 5 | @end 6 | 7 | @interface Foo(copycat) 8 | - (void) instance_method_fromcat; 9 | + (void) class_method_fromcat; 10 | @end 11 | 12 | @implementation Foo(copycat) 13 | - (void) instance_method_fromcat {} 14 | + (void) class_method_fromcat {} 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-category-warning/foo.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | -(void) instance_method; 5 | +(void) class_method; 6 | @end 7 | 8 | 9 | @implementation Foo 10 | -(void) instance_method {} 11 | +(void) class_method {} 12 | @end 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-class-alias/test.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | @end 5 | 6 | @implementation Foo 7 | @end 8 | 9 | 10 | int main() 11 | { 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-class-patching-alias/exported_symbols: -------------------------------------------------------------------------------- 1 | _globalFoo 2 | _ConstantFooReference 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-class-patching-alias/foo_alias.c: -------------------------------------------------------------------------------- 1 | __asm__(".globl _ConstantFooReference\n" 2 | ".set _ConstantFooReference, _OBJC_CLASS_$_Foo\n"); 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-exported_symbols_list/foo.exp: -------------------------------------------------------------------------------- 1 | .objc_class_name_Foo 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-exported_symbols_list/foo.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Foo : NSObject 4 | @end 5 | 6 | @implementation Foo 7 | @end 8 | 9 | 10 | 11 | @interface Bar : NSObject 12 | @end 13 | 14 | @implementation Bar 15 | @end 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-properties/Makefile: -------------------------------------------------------------------------------- 1 | 2 | TESTROOT = ../.. 3 | include ${TESTROOT}/include/common.makefile 4 | 5 | 6 | # 7 | # Verify an Objective-C object file when run through ld -r is unaltered. 8 | # 9 | # 10 | 11 | run: all 12 | 13 | all: 14 | ${CC} ${CCFLAGS} test.m -dynamiclib -framework Foundation -o libtest.dylib 15 | ${PASS_IFF_GOOD_MACHO} libtest.dylib 16 | 17 | clean: 18 | rm -rf libtest.dylib 19 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-references/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to verify an Objective-C object file is parsed to find the proper class references 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-selector-coalescing/main.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | NSString* other() 5 | { 6 | return [NSString stringWithUTF8String:"hello"]; 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-selector-coalescing/other.m: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | 5 | int main() 6 | { 7 | [NSString stringWithUTF8String:"hello"]; 8 | return 0; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-stubs-objcmsgsend-dynamic-lookup/Makefile: -------------------------------------------------------------------------------- 1 | TESTROOT = ../.. 2 | include ${TESTROOT}/include/common.makefile 3 | 4 | # 5 | # Verify that objc_stubs pass works when using dynamic symbol lookup 6 | # 7 | 8 | all: 9 | ${CC} ${CCFLAGS} main.m -undefined dynamic_lookup 10 | ${PASS_IFF_GOOD_MACHO} a.out 11 | 12 | clean: 13 | rm -rf a.out 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-stubs-objcmsgsend-dynamic-lookup/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keith/ld64/7042a5f6bea71bc33c0a083911e03f86704f2e23/unit-tests/test-cases/objc-stubs-objcmsgsend-dynamic-lookup/a.out -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-stubs-objcmsgsend-dynamic-lookup/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface Foo: NSObject 4 | +(int)foo; 5 | @end 6 | 7 | @implementation Foo 8 | 9 | +(int)foo { 10 | return 0; 11 | } 12 | @end 13 | 14 | int main() { 15 | printf("%d\n", [Foo foo]); 16 | } 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-stubs-selname-order/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface Foo: NSObject 4 | +(int)foo; 5 | +(int)bar; 6 | @end 7 | 8 | @implementation Foo 9 | 10 | +(int)foo { 11 | return 0; 12 | } 13 | 14 | +(int)bar { 15 | return 0; 16 | } 17 | @end 18 | 19 | int main() { 20 | printf("%d\n", [Foo foo]); 21 | printf("%d\n", [Foo bar]); 22 | } 23 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-visibility/bar.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | __attribute__((visibility("hidden"))) 5 | @interface Bar : NSData 6 | - (NSArray*) bar; 7 | @end 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-visibility/bar.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | #include "bar.h" 5 | 6 | 7 | @implementation Bar 8 | - (NSArray*) bar 9 | { 10 | return [NSArray array]; 11 | } 12 | @end 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-visibility/foo.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | 5 | @interface Foo : NSObject 6 | - (NSString*) foo; 7 | @end 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/objc-visibility/foo.m: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "foo.h" 5 | #include "bar.h" 6 | 7 | @implementation Foo 8 | - (NSString*) foo 9 | { 10 | [Bar alloc]; 11 | return [NSString stringWithUTF8String:"hello"]; 12 | } 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-ans/main.expected: -------------------------------------------------------------------------------- 1 | __Z3barPN12_GLOBAL__N_112myanonstructE 2 | __ZN3wow12_GLOBAL__N_15innerEv 3 | __ZN12_GLOBAL__N_13bazEPNS_12myanonstructE 4 | __ZN12_GLOBAL__N_13fooEv 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-ans/main.order: -------------------------------------------------------------------------------- 1 | __Z3barPN12_GLOBAL__N_112myanonstructE 2 | __ZN3wow12_GLOBAL__N_15innerEv 3 | __ZN12_GLOBAL__N_13bazEPNS_12myanonstructE 4 | __ZN12_GLOBAL__N_13fooEv 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-archive/foo.c: -------------------------------------------------------------------------------- 1 | void foo1() { } 2 | void foo2() {} 3 | void foo3() {} 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-archive/main.expected: -------------------------------------------------------------------------------- 1 | _foo2 2 | _main 3 | _foo3 4 | _foo1 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-archive/main.order: -------------------------------------------------------------------------------- 1 | _foo2 2 | _main 3 | libfoo.a(foo.o):_foo3 4 | _foo1 5 | 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-thinlto/test.c: -------------------------------------------------------------------------------- 1 | __attribute__((visibility("hidden"))) 2 | int foo() asm("_foo.llvm.ABCDEFG1"); 3 | int foo() { return 0; } 4 | 5 | void api() { 6 | foo(); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-thinlto/test.expected: -------------------------------------------------------------------------------- 1 | _bar 2 | _foo 3 | _api3 4 | _api 5 | _api2 6 | _foo 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-thinlto/test.order: -------------------------------------------------------------------------------- 1 | _bar 2 | _foo 3 | _api3 4 | _api 5 | _api2 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-thinlto/test2.c: -------------------------------------------------------------------------------- 1 | __attribute__((visibility("hidden"))) 2 | int foo() asm("_foo.llvm.ABCDEFG2"); 3 | int foo() { return 0; } 4 | 5 | void api2() { 6 | foo(); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-thinlto/test3.c: -------------------------------------------------------------------------------- 1 | __attribute__((visibility("hidden"))) 2 | int foo() asm("_bar.llvm.1234567"); 3 | int foo() { return 0; } 4 | 5 | void api3() { 6 | foo(); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-zero-fill/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int xyz_f2; 3 | int xyz_f4; 4 | int other; 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-zero-fill/main.expected: -------------------------------------------------------------------------------- 1 | _xyz_f4 2 | _xyz_mi4 3 | _xyz_f2 4 | _xyz_m3 5 | _xyz_m1 6 | _xyz_ms1 7 | _xyz_mi3 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file-zero-fill/main.order: -------------------------------------------------------------------------------- 1 | _xyz_f4 2 | _xyz_mi4 3 | _xyz_f2 4 | _xyz_m3 5 | _xyz_m1 6 | _xyz_ms1 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file/extra.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .text 4 | .align 4 5 | 6 | .globl _foo1 7 | _foo1: nop 8 | 9 | .globl _aaa2 10 | _aaa2: 11 | .globl _bbb2 12 | .private_extern _bbb2 13 | _bbb2: 14 | _ccc2: 15 | nop 16 | 17 | .globl _bbb3 18 | _aaa3: 19 | _bbb3: 20 | _ccc3: 21 | nop 22 | 23 | 24 | _aaa4: 25 | nop 26 | 27 | #if SUBSECTIONS 28 | .subsections_via_symbols 29 | #endif 30 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file/main1.expected: -------------------------------------------------------------------------------- 1 | _main4 2 | _main3 3 | _main 4 | _main2 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file/main1.order: -------------------------------------------------------------------------------- 1 | _main4 2 | _main3 3 | 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file/main2.expected: -------------------------------------------------------------------------------- 1 | _main3 2 | _foo1 3 | _aaa2 4 | _bbb2 5 | _ccc2 6 | _aaa3 7 | _bbb3 8 | _ccc3 9 | _aaa4 10 | _main4 11 | _main2 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file/main2.order: -------------------------------------------------------------------------------- 1 | _main3 2 | _aaa3 3 | _main4 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file/main3.expected: -------------------------------------------------------------------------------- 1 | _main4 2 | _main3 3 | _main 4 | _main2 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file/main3.order: -------------------------------------------------------------------------------- 1 | 2 | # spaces before and after main4 3 | main.o: _main4 4 | # 5 | main.o: _main3# trailing comment 6 | # 7 | 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file/main4.expected: -------------------------------------------------------------------------------- 1 | _aaa2 2 | _main3 3 | _main2 4 | _main4 5 | _foo1 6 | _bbb3 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/order_file/main4.order: -------------------------------------------------------------------------------- 1 | 2 | 3 | _bbb2 4 | _main3 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/pagezero-alignment/main.c: -------------------------------------------------------------------------------- 1 | 2 | int x = 5; 3 | 4 | int main() 5 | { 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/pagezero-none-segaddr-zero/main.c: -------------------------------------------------------------------------------- 1 | int main() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/pipelined-linking/bar.c: -------------------------------------------------------------------------------- 1 | void bar() 2 | { 3 | } 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/pipelined-linking/cat.c: -------------------------------------------------------------------------------- 1 | void cat() 2 | { 3 | } 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/pipelined-linking/foo.c: -------------------------------------------------------------------------------- 1 | 2 | void foo() 3 | { 4 | } 5 | 6 | int main() 7 | { 8 | return 0; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/prebound-split-seg/address_table: -------------------------------------------------------------------------------- 1 | # comment 2 | 0x91000000 0xA1000000 /foo/bar/libbar.dylib 3 | # 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/preload-fixup-chains/main.c: -------------------------------------------------------------------------------- 1 | int main() { for (;;);} 2 | int (*fptr)() = &main; 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/preload-section_order/extra.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | .section __MYSEG,__my_xxx 5 | _x: .long 0 6 | 7 | 8 | .section __MYSEG,__my_yyy 9 | _y: .long 0 10 | 11 | 12 | .section __MYSEG,__my_zzz 13 | _z: .long 0 14 | 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/preload-section_order/main.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void entry() { 4 | } 5 | 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/preload-section_order/main1.expected: -------------------------------------------------------------------------------- 1 | sectname __my_yyy 2 | sectname __my_ccc 3 | sectname __my_aaa 4 | sectname __my_bbb 5 | sectname __my_ddd 6 | sectname __my_xxx 7 | sectname __my_zzz 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/preload-section_order/main2.expected: -------------------------------------------------------------------------------- 1 | sectname __my_iii 2 | sectname __my_aaa 3 | sectname __my_jjj 4 | sectname __my_bbb 5 | sectname __my_ddd 6 | sectname __my_xxx 7 | sectname __my_zzz 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/preload-section_order/more.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .section __MYSEG,__my_aaa 4 | _a: .long 0 5 | 6 | 7 | .section __MYSEG,__my_bbb 8 | _b: .long 0 9 | 10 | 11 | .section __MYSEG,__my_ccc 12 | _c: .long 0 13 | 14 | 15 | 16 | .section __MYSEG,__my_ddd 17 | _d: .long 0 18 | 19 | 20 | -------------------------------------------------------------------------------- /unit-tests/test-cases/preload-segment_order/a.c: -------------------------------------------------------------------------------- 1 | 2 | extern const char* mystring; 3 | 4 | const char** myp = &mystring; 5 | 6 | int com; 7 | 8 | const char* inc() { 9 | ++com; 10 | return ""; 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/preload-segment_order/b.c: -------------------------------------------------------------------------------- 1 | const char* mystring = "hello"; 2 | 3 | int var = 10; 4 | 5 | const char* incget() { 6 | ++var; 7 | return mystring; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/preload-segment_order/main-segs.expected: -------------------------------------------------------------------------------- 1 | segname __ROM2 2 | segname __ROM 3 | segname __RAM 4 | segname __ZF 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/preload-segment_order/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern const char** myp; 3 | 4 | 5 | const char** entry(int i) { 6 | if ( i ) { 7 | *myp = "help"; 8 | } 9 | return myp; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/private-non-lazy/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int __attribute__((visibility("hidden"))) foo = 0; 3 | 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/private-non-lazy/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to check that a non-lazy-pointer in foo.o to a private-extern symbol in bar.o will properly survive ld -r 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/private-non-lazy/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | extern int foo; 4 | 5 | int getfoo() { return foo; } 6 | 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-and-use/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar() 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-and-use/baz.c: -------------------------------------------------------------------------------- 1 | 2 | int baz() 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-and-use/foo.c: -------------------------------------------------------------------------------- 1 | extern int bar(); 2 | extern int baz(); 3 | 4 | void* pbar = &bar; 5 | 6 | #if USE_BAZ 7 | void* pbaz = &baz; 8 | #endif 9 | 10 | int foo() 11 | { 12 | #if USE_BAZ 13 | baz(); 14 | #endif 15 | return bar(); 16 | } 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-and-use/pub.c: -------------------------------------------------------------------------------- 1 | 2 | int pub() 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-cases/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-cases/baz.c: -------------------------------------------------------------------------------- 1 | 2 | int baz (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-cases/foo.c: -------------------------------------------------------------------------------- 1 | int foo (void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-flag/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar(void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-flag/foo.c: -------------------------------------------------------------------------------- 1 | int foo(void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-layers/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-layers/baz.c: -------------------------------------------------------------------------------- 1 | 2 | int baz (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-layers/foo.c: -------------------------------------------------------------------------------- 1 | int foo (void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-layers/main.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | extern void baz(); 4 | extern void bar(); 5 | extern void foo(); 6 | 7 | 8 | int main() 9 | { 10 | baz(); 11 | bar(); 12 | foo(); 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-optimizations-indirect/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-optimizations-indirect/foo.c: -------------------------------------------------------------------------------- 1 | int foo (void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-optimizations-indirect/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | 4 | int main() 5 | { 6 | bar(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-optimizations-indirect/middle.c: -------------------------------------------------------------------------------- 1 | 2 | void middle() {} 3 | 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-optimizations-indirect/other.c: -------------------------------------------------------------------------------- 1 | void other() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-optimizations/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-optimizations/foo.c: -------------------------------------------------------------------------------- 1 | int foo (void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-optimizations/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | 4 | int main() 5 | { 6 | #if CALL_BAR 7 | bar(); 8 | #endif 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-relative-paths/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar (void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-relative-paths/baz.c: -------------------------------------------------------------------------------- 1 | 2 | int baz(void) 3 | { 4 | return 1; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-relative-paths/foo.c: -------------------------------------------------------------------------------- 1 | int foo (void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-relative-paths/main.c: -------------------------------------------------------------------------------- 1 | extern int foo(); 2 | extern int bar(); 3 | extern int wrap(); 4 | 5 | int main() 6 | { 7 | foo(); 8 | bar(); 9 | wrap(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-relative-paths/wrap.c: -------------------------------------------------------------------------------- 1 | int wrap() { return 0; } 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-symbol/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar(void) 3 | { 4 | return 1; 5 | } 6 | 7 | __attribute__((weak)) 8 | void bar_weak() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-symbol/foo.c: -------------------------------------------------------------------------------- 1 | 2 | #if USE_MY 3 | extern int mybar(); 4 | #else 5 | extern int bar(); 6 | #endif 7 | 8 | int foo(void) 9 | { 10 | #if USE_MY 11 | return mybar() + 1; 12 | #else 13 | return bar() + 1; 14 | #endif 15 | } 16 | 17 | #if USE_MY 18 | void* p = &mybar; 19 | #else 20 | void* p = &bar; 21 | #endif 22 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-symbol/foo.exp: -------------------------------------------------------------------------------- 1 | _foo 2 | _bar 3 | _bar_weak 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-symbol/foo2.exp: -------------------------------------------------------------------------------- 1 | _foo 2 | _mybar 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-symbol/main1.c: -------------------------------------------------------------------------------- 1 | extern int foo(); 2 | extern int bar(); 3 | extern int bar_weak(); 4 | 5 | int main() 6 | { 7 | foo(); 8 | bar(); 9 | bar_weak(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-symbol/main2.c: -------------------------------------------------------------------------------- 1 | extern int foo(); 2 | extern int mybar(); 3 | 4 | int main() 5 | { 6 | foo(); 7 | mybar(); 8 | return 0; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-weak/bar.c: -------------------------------------------------------------------------------- 1 | int bar(void) { 2 | return 1; 3 | } 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-weak/foo.c: -------------------------------------------------------------------------------- 1 | int foo(void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/re-export-weak/main.c: -------------------------------------------------------------------------------- 1 | extern int bar(void); 2 | int main(int argc, char **argv) { 3 | return bar(); 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/read-only-relocs/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int b=0; 3 | 4 | void func() {} 5 | 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/read-only-relocs/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern int b; 3 | extern void func(); 4 | 5 | int main() 6 | { 7 | func(); 8 | return b; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/read-only-relocs/test_bind.c: -------------------------------------------------------------------------------- 1 | 2 | extern int b; 3 | extern void func(); 4 | 5 | int test_bind() 6 | { 7 | func(); 8 | return b; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/read-only-relocs/test_rebase.c: -------------------------------------------------------------------------------- 1 | 2 | int a=0; 3 | 4 | int test_rebase() 5 | { 6 | return a; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/rebase-basic/bar.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface Bar : NSObject 4 | 5 | -(void) blah; 6 | 7 | @end 8 | 9 | @implementation Bar 10 | 11 | -(void) blah {} 12 | 13 | @end -------------------------------------------------------------------------------- /unit-tests/test-cases/rebase-basic/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to see that a dylib run through the rebase tool is the same as if the dylib was originally built at that address 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/rebase-basic/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int foo() { return 10; } 3 | 4 | void* foop = &foo; 5 | 6 | int glob = 5; 7 | 8 | int* globp = &glob; 9 | 10 | 11 | int big[3000]; 12 | 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/reexport_symbols_list/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int barb(void) 3 | { 4 | return 1; 5 | } 6 | 7 | int bart(void) 8 | { 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/reexport_symbols_list/bart.exp: -------------------------------------------------------------------------------- 1 | _bart 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/reexport_symbols_list/foo.c: -------------------------------------------------------------------------------- 1 | int foo(void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/reexport_symbols_list/foo.exp: -------------------------------------------------------------------------------- 1 | _foo 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/reexport_symbols_list/junk.exp: -------------------------------------------------------------------------------- 1 | _junk 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/reexport_symbols_list/main1.c: -------------------------------------------------------------------------------- 1 | extern int foo(); 2 | extern int bart(); 3 | 4 | int main() 5 | { 6 | foo(); 7 | bart(); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/relocs-asm/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to verify a .o file can round-trip through ld -r correctly. The ObjectDump utility is used 2 | dump a "canonical" textual representation of a .o file. The before and after .o files are then diff'ed. 3 | No differences means this test passes 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/relocs-c2/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to verify a .o file can round-trip through ld -r correctly. The ObjectDump utility is used 2 | dump a "canonical" textual representation of a .o file. The before and after .o files are then diff'ed. 3 | No differences means this test passes 4 | 5 | Currently for ppc64 the .o's alternate! in content 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/relocs-literals3/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to verify a .o file can round-trip through ld -r correctly. The ObjectDump utility is used 2 | dump a "canonical" textual representation of a .o file. The before and after .o files are then diff'ed. 3 | No differences means this test passes 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/relocs-objc/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to verify a .o file can round-trip through ld -r correctly. The ObjectDump utility is used 2 | dump a "canonical" textual representation of a .o file. The before and after .o files are then diff'ed. 3 | No differences means this test passes 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/sectcreate-dead_strip/main.c: -------------------------------------------------------------------------------- 1 | 2 | int main() 3 | { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/sectcreate-dead_strip/sect_content: -------------------------------------------------------------------------------- 1 | hello 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/section-names-long/a.s: -------------------------------------------------------------------------------- 1 | 2 | .section __TEXT,__aaaaaaaaaaaaaa 3 | _at: .space 128 4 | 5 | .section __DATA,__aaaaaaaaaaaaaa 6 | _ad: .space 128 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/section-names-long/b.s: -------------------------------------------------------------------------------- 1 | 2 | .section __TEXT,__bbbbbbbbbbbbbb 3 | _bt: .space 128 4 | 5 | .section __DATA,__bbbbbbbbbbbbbb 6 | _bd: .space 128 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/section-names-long/c.s: -------------------------------------------------------------------------------- 1 | 2 | .section __TEXT,__cccccccccccccc 3 | _ct: .space 128 4 | 5 | 6 | .section __DATA,__cccccccccccccc 7 | _cd: .space 128 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/section-names-long/main.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main() { return 0; } 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/segment-labels/test.c: -------------------------------------------------------------------------------- 1 | extern char text_start[] __asm("segment$start$__TEXT"); 2 | extern char text_end[] __asm("segment$end$__TEXT"); 3 | extern char text_text_start[] __asm("section$start$__TEXT$__text"); 4 | 5 | void* a = &text_start; 6 | void* b = &text_end; 7 | void* c = &text_text_start; 8 | 9 | void start(void) 10 | { 11 | } 12 | 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/segment-order/expected.order: -------------------------------------------------------------------------------- 1 | _sym_kkk 2 | _sym_jjj 3 | _sym_lll 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/segment-order/main.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main() { return 0; } 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/segment-order/segJJJ.s: -------------------------------------------------------------------------------- 1 | 2 | .section __JJJ,__jjj 3 | _sym_jjj: .space 128 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/segment-order/segKKK.s: -------------------------------------------------------------------------------- 1 | 2 | .section __KKK,__kkk 3 | _sym_kkk: .space 128 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/segment-order/segLLL.s: -------------------------------------------------------------------------------- 1 | 2 | .section __LLL,__lll 3 | _sym_lll: .space 128 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/shared-cache-dylib/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int x; 4 | 5 | int foo() { return x; } 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/slow-x86-stubs/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | fprintf(stdout, "hello\n"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/sparse-versioned-framework/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() { } 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/sparse-versioned-framework/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | 4 | int main() 5 | { 6 | foo(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/special-labels/extra.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .data 4 | 5 | _foo: .long 0 6 | lother: .long 0 7 | L123: .long 0 8 | _bar: .long 0 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/static-executable-fixupchains-section/test.c: -------------------------------------------------------------------------------- 1 | int main(void); 2 | void *my_ptr1 = &main; 3 | void *my_ptr2 = &main; 4 | 5 | int main(void) { } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/static-executable-img-base-zeropage/test.c: -------------------------------------------------------------------------------- 1 | int main() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/static-executable-pie/bad.c: -------------------------------------------------------------------------------- 1 | static int my; 2 | 3 | int getmy() 4 | { 5 | #if __x86_64__ 6 | __asm(" .quad _my"); 7 | #endif 8 | return my; 9 | } 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/static-executable-pie/test.c: -------------------------------------------------------------------------------- 1 | 2 | int a; 3 | int b = 5; 4 | int* pa = &a; 5 | int* pb = &b; 6 | 7 | int foo() 8 | { 9 | *pa = 4; 10 | return a+b; 11 | } 12 | 13 | 14 | int entry() 15 | { 16 | return foo(); 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /unit-tests/test-cases/static-executable-weak-defines/test.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | __attribute__((weak)) int foo() 5 | { 6 | return 0; 7 | } 8 | 9 | 10 | int entry() 11 | { 12 | return foo(); 13 | } 14 | 15 | // pointer to weak function might trigger external relocation 16 | void* pfoo = &foo; 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/static-executable/test.c: -------------------------------------------------------------------------------- 1 | 2 | int a; 3 | int b = 5; 4 | 5 | int foo() 6 | { 7 | return a+b; 8 | } 9 | 10 | 11 | int entry() 12 | { 13 | return foo(); 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/static-strip/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld can link a static executable (requires non-public archives) 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/strip-test2/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keith/ld64/7042a5f6bea71bc33c0a083911e03f86704f2e23/unit-tests/test-cases/strip-test2/Makefile -------------------------------------------------------------------------------- /unit-tests/test-cases/strip-test2/main.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | std::vector stuff; 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/strip-test3/Makefile.newtest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keith/ld64/7042a5f6bea71bc33c0a083911e03f86704f2e23/unit-tests/test-cases/strip-test3/Makefile.newtest -------------------------------------------------------------------------------- /unit-tests/test-cases/strip-test3/main.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | std::vector stuff; 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/strip_local/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int __attribute__((visibility("hidden"))) data = 3; 4 | 5 | void __attribute__((visibility("hidden"))) func(int x) { } 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/stripped-indirect-symbol-table/a.c: -------------------------------------------------------------------------------- 1 | 2 | int aData = 0; 3 | 4 | void a() 5 | { 6 | ++aData; 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/stripped-indirect-symbol-table/b.c: -------------------------------------------------------------------------------- 1 | 2 | int bData = 0; 3 | 4 | void b() 5 | { 6 | ++bData; 7 | } 8 | 9 | void bb() 10 | { 11 | ++bData; 12 | } 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/stripped-indirect-symbol-table/c.c: -------------------------------------------------------------------------------- 1 | extern void b(); 2 | extern void bb(); 3 | 4 | extern void func(void*); 5 | 6 | 7 | void c() 8 | { 9 | func(&b); 10 | func(&bb); 11 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/stripped-indirect-symbol-table/func.c: -------------------------------------------------------------------------------- 1 | void func(void* x) {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/stripped-indirect-symbol-table/strip.list: -------------------------------------------------------------------------------- 1 | _b 2 | _bb 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/stub-generation-weak/foo.c: -------------------------------------------------------------------------------- 1 | 2 | void foo() {} 3 | void bar() {} 4 | void baz() {} 5 | 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/swift-force-load-sym-redirect-both/client.c: -------------------------------------------------------------------------------- 1 | __attribute__((weak)) extern void *_swift_FORCE_LOAD_$_swiftFoundation; 2 | __attribute__((weak)) extern void *foovar; 3 | 4 | __attribute__((section("__DATA,__const"))) 5 | const void *_swift_FORCE_LOAD_$_swiftFoundation_MINE = &_swift_FORCE_LOAD_$_swiftFoundation; 6 | 7 | __attribute__((section("__DATA,__const"))) 8 | const void *foovar_MINE = &foovar; 9 | 10 | int main() {} 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/swift-force-load-sym-redirect-other/client.c: -------------------------------------------------------------------------------- 1 | __attribute__((weak)) extern void *_swift_FORCE_LOAD_$_swiftFoundation; 2 | __attribute__((weak)) extern void *foovar; 3 | 4 | __attribute__((section("__DATA,__const"))) 5 | const void *_swift_FORCE_LOAD_$_swiftFoundation_MINE = &_swift_FORCE_LOAD_$_swiftFoundation; 6 | 7 | __attribute__((section("__DATA,__const"))) 8 | const void *foovar_MINE = &foovar; 9 | 10 | int main() {} 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/swift-force-load-sym-redirect-other/lib.c: -------------------------------------------------------------------------------- 1 | const void *_swift_FORCE_LOAD_$_swiftFoundation; 2 | 3 | char foovar_redirect __asm("$ld$previous$we_redirected_some_other_global_variable$1.0.0$1$1.0$99.0$_foovar$"); 4 | char foovar_redirectios __asm("$ld$previous$we_redirected_some_other_global_variable$1.0.0$2$1.0$99.0$_foovar$"); 5 | const void *foovar; 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/swift-force-load-sym-redirect/client.c: -------------------------------------------------------------------------------- 1 | __attribute__((weak)) extern void *_swift_FORCE_LOAD_$_swiftFoundation; 2 | 3 | __attribute__((section("__DATA,__const"))) 4 | const void *_swift_FORCE_LOAD_$_swiftFoundation_MINE = &_swift_FORCE_LOAD_$_swiftFoundation; 5 | 6 | int main() {} 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/swift-force-load-sym-redirect/lib.c: -------------------------------------------------------------------------------- 1 | char foo2 __asm("$ld$previous$we_redirected_the_force_load$1.0.0$1$1.0$99.0$__swift_FORCE_LOAD_$_swiftFoundation$"); 2 | char fooios2 __asm("$ld$previous$we_redirected_the_force_load$1.0.0$2$1.0$99.0$__swift_FORCE_LOAD_$_swiftFoundation$"); 3 | const void *_swift_FORCE_LOAD_$_swiftFoundation; 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/swift-force-load-sym/client.c: -------------------------------------------------------------------------------- 1 | __attribute__((weak)) extern void *_swift_FORCE_LOAD_$_swiftFoundation; 2 | 3 | __attribute__((section("__DATA,__const"))) 4 | const void *_swift_FORCE_LOAD_$_swiftFoundation_MINE = &_swift_FORCE_LOAD_$_swiftFoundation; 5 | 6 | int main() {} 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/swift-force-load-sym/lib.c: -------------------------------------------------------------------------------- 1 | const void *_swift_FORCE_LOAD_$_swiftFoundation; 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/switch-jump-table/interpose.exp: -------------------------------------------------------------------------------- 1 | _foo 2 | _bar 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/switch-jump-table/main.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | return 0; 4 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-hiding-umbrella/bar.c: -------------------------------------------------------------------------------- 1 | void bar() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-hiding-umbrella/foo.c: -------------------------------------------------------------------------------- 1 | 2 | void foo() {} 3 | 4 | #define SYMBOL_NOT_HERE_IN_10_6(sym) \ 5 | extern const char sym##_tmp __asm("$ld$hide$os10.6$_" #sym ); const char sym##_tmp = 0; 6 | 7 | SYMBOL_NOT_HERE_IN_10_6(bar) 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-hiding-umbrella/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | extern void bar(); 4 | 5 | 6 | int main() 7 | { 8 | foo(); 9 | bar(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-move-and-section-rename/foo.list: -------------------------------------------------------------------------------- 1 | libfoo.a(*.o):* 2 | 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-move-and-section-rename/foo1.c: -------------------------------------------------------------------------------- 1 | void foo1() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-move-and-section-rename/foo2.c: -------------------------------------------------------------------------------- 1 | void foo2() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-move-and-section-rename/hot.list: -------------------------------------------------------------------------------- 1 | _def 2 | _com3 3 | 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-move-and-section-rename/main.c: -------------------------------------------------------------------------------- 1 | 2 | void mm() 3 | { 4 | } 5 | 6 | void s1() { 7 | mm(); 8 | } 9 | 10 | void s2() { 11 | mm(); 12 | } 13 | 14 | int main() 15 | { 16 | s1(); 17 | s2(); 18 | return 0; 19 | } 20 | 21 | 22 | int abc = 10; 23 | int def = 20; 24 | int ghi = 30; 25 | 26 | int com1; 27 | int com2; 28 | int com3; 29 | int com4; 30 | 31 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-move-and-section-rename/spec.list: -------------------------------------------------------------------------------- 1 | _s1 2 | _s2 3 | 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-moving/aaa.c: -------------------------------------------------------------------------------- 1 | 2 | void aaa() {} 3 | 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-moving/bar.c: -------------------------------------------------------------------------------- 1 | void bar() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-moving/bbb.c: -------------------------------------------------------------------------------- 1 | void bbb() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-moving/foo.c: -------------------------------------------------------------------------------- 1 | 2 | void foo() {} 3 | 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-moving/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | extern void bar(); 4 | 5 | extern void aaa(); 6 | extern void bbb(); 7 | 8 | 9 | int main() 10 | { 11 | foo(); 12 | bar(); 13 | aaa(); 14 | bbb(); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-section-move/other.c: -------------------------------------------------------------------------------- 1 | 2 | static int mylocal() 3 | { 4 | return 1; 5 | } 6 | 7 | void* otherget() { return mylocal; } 8 | 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-section-move/ram1.symbols: -------------------------------------------------------------------------------- 1 | _com 2 | _abc 3 | 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-section-move/rom1.symbols: -------------------------------------------------------------------------------- 1 | _foo 2 | _s1 3 | main.o:_mylocal 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-warn-cpp-extern-c/bar.c: -------------------------------------------------------------------------------- 1 | int bar() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-warn-cpp-extern-c/foo.c: -------------------------------------------------------------------------------- 1 | int foo() { return 0; } 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/symbol-warn-cpp-extern-c/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | extern int foo(); 3 | extern int bar(); 4 | 5 | int main() { 6 | return foo() + bar(); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/synthetic-dylib-lc-order/bar_moved.c: -------------------------------------------------------------------------------- 1 | const char bar_old __asm("$ld$previous$@rpath/libbar.dylib$$1$1.0$100.0$_bar"); 2 | const char bar_old_ios __asm("$ld$previous$@rpath/libbar.dylib$$2$1.0$100.0$_bar"); 3 | __attribute((visibility("default"))) int bar = 0; 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/synthetic-dylib-lc-order/baz_moved.c: -------------------------------------------------------------------------------- 1 | const char baz_old __asm("$ld$previous$@rpath/libbaz.dylib$$1$1.0$100.0$_baz"); 2 | const char baz_old_ios __asm("$ld$previous$@rpath/libbaz.dylib$$2$1.0$100.0$_baz"); 3 | __attribute((visibility("default"))) int baz = 0; 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/synthetic-dylib-lc-order/main.c: -------------------------------------------------------------------------------- 1 | extern int bar; 2 | extern int baz; 3 | 4 | int main() { 5 | return bar + baz; 6 | } 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-and-archive-code/foo_code.c: -------------------------------------------------------------------------------- 1 | 2 | int foo() { return 10; } 3 | 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-and-archive-code/foo_data.c: -------------------------------------------------------------------------------- 1 | 2 | int foo = 5; 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-and-archive-code/foo_tent.c: -------------------------------------------------------------------------------- 1 | 2 | int foo; 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-and-archive-code/junk.c: -------------------------------------------------------------------------------- 1 | void junk() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-and-archive-code/main.c: -------------------------------------------------------------------------------- 1 | 2 | int foo; 3 | 4 | int main() 5 | { 6 | foo = 3; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-and-archive/bar.c: -------------------------------------------------------------------------------- 1 | void bar() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-and-archive/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | 4 | void foo() { bar(); } 5 | 6 | int var = 9; 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-and-archive/main.c: -------------------------------------------------------------------------------- 1 | 2 | int var; 3 | int other_tent; 4 | 5 | int main() 6 | { 7 | var = 3; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-and-dylib/bar.c: -------------------------------------------------------------------------------- 1 | void bar() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-and-dylib/foo.c: -------------------------------------------------------------------------------- 1 | void foo() {} 2 | int var = 9; 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-and-dylib/main.c: -------------------------------------------------------------------------------- 1 | 2 | int var; 3 | 4 | int main() 5 | { 6 | var = 3; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-to-real-hidden/test.c: -------------------------------------------------------------------------------- 1 | 2 | // tentative definitions 3 | int tent1; 4 | int tent2; 5 | int __attribute__((visibility("hidden"))) tent3; 6 | 7 | // initialized to point to tentative definitions 8 | int* pa = &tent1; 9 | int* pb = &tent2; 10 | int* pc = &tent3; 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-to-real-r/test.c: -------------------------------------------------------------------------------- 1 | 2 | void foo() {} 3 | 4 | int a; 5 | int b; 6 | int c; 7 | 8 | 9 | 10 | int* pa = &a; 11 | int* pb = &b; 12 | int* pc = &c; 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-to-real/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is to verify that -r -d will transform a tentative definition into a real one. 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tentative-to-real/test.c: -------------------------------------------------------------------------------- 1 | 2 | // a tentative definition 3 | int a; 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/thumb-pointer/bar.c: -------------------------------------------------------------------------------- 1 | 2 | void bar1() {} 3 | void bar2() {} 4 | char bar_array[3] = { 1,2,3 }; 5 | 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/thumb-pointer/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | extern void bar1(); 4 | extern void bar2(); 5 | extern char bar_array[]; 6 | 7 | void foo1() {} 8 | void foo2() {} 9 | char foo_array[3] = { 1,2,3 }; 10 | 11 | 12 | 13 | void* foostuff[] = { &foo1, &foo2, foo_array, &foo_array[3] }; 14 | void* barstuff[] = { &bar1, &bar2, bar_array, &bar_array[3] }; 15 | -------------------------------------------------------------------------------- /unit-tests/test-cases/tlv-dylib/foo.c: -------------------------------------------------------------------------------- 1 | 2 | // foo is an exported thread local variable 3 | __thread int foo[1024]; 4 | 5 | // _bar is an exported regular variable 6 | int bar = 5; 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/umbrella-dylib/a.c: -------------------------------------------------------------------------------- 1 | 2 | extern void c2(); 3 | 4 | void a1(void) 5 | { 6 | c2(); 7 | } 8 | 9 | void a2(void) 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/umbrella-dylib/b.c: -------------------------------------------------------------------------------- 1 | 2 | extern void c1(); 3 | 4 | void b1(void) 5 | { 6 | c1(); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/umbrella-dylib/c.c: -------------------------------------------------------------------------------- 1 | 2 | extern void a2(); 3 | 4 | void c1(void) 5 | { 6 | a2(); 7 | } 8 | 9 | void c2(void) 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/umbrella-dylib/main.c: -------------------------------------------------------------------------------- 1 | extern void c1(); 2 | extern void a1(); 3 | int main() 4 | { 5 | a1(); 6 | c1(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/umbrella-framework/Big: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keith/ld64/7042a5f6bea71bc33c0a083911e03f86704f2e23/unit-tests/test-cases/umbrella-framework/Big -------------------------------------------------------------------------------- /unit-tests/test-cases/umbrella-framework/a.c: -------------------------------------------------------------------------------- 1 | 2 | extern void c2(); 3 | 4 | void a1(void) 5 | { 6 | c2(); 7 | } 8 | 9 | void a2(void) 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/umbrella-framework/b.c: -------------------------------------------------------------------------------- 1 | 2 | extern void c1(); 3 | 4 | void b1(void) 5 | { 6 | c1(); 7 | } 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/umbrella-framework/c.c: -------------------------------------------------------------------------------- 1 | 2 | extern void a2(); 3 | 4 | void c1(void) 5 | { 6 | a2(); 7 | } 8 | 9 | void c2(void) 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/umbrella-framework/main.c: -------------------------------------------------------------------------------- 1 | extern void c1(); 2 | extern void a1(); 3 | int main() 4 | { 5 | a1(); 6 | c1(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/unexported_symbols_list-r/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern int fooCount; 3 | extern int barCount; 4 | 5 | void foo() { fooCount++; } 6 | void bar() { barCount++; } 7 | int global = 4; 8 | int googoo = 5; 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/unexported_symbols_list-r/foo.exp: -------------------------------------------------------------------------------- 1 | _foo 2 | _global 3 | 4 | -------------------------------------------------------------------------------- /unit-tests/test-cases/utf16-nul/other.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .section __TEXT,__ustring 4 | .align 1 5 | ___utf16_string_3: 6 | .short 0x00fc, 0x0062, 0x0065, 0x0072, 0x0000 7 | 8 | ___utf16_string_4: 9 | .short 0x0073, 0x0074, 0x00fc, 0x0066, 0x0066, 0x0000 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/utf16-nul/withnul.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .section __TEXT,__ustring 4 | .align 1 5 | ___utf16_string_1: 6 | .short 0x00fc, 0x0062, 0x0065, 0x0072, 0x0000, 0x0073, 0x0074, 0x00fc, 0x0066, 0x0066, 0x0000 7 | 8 | 9 | -------------------------------------------------------------------------------- /unit-tests/test-cases/visibility-warning-dylib-v-archive/bar.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void __attribute__((weak,visibility("hidden"))) foo() 4 | { 5 | 6 | } 7 | 8 | 9 | void bar() 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/visibility-warning-dylib-v-archive/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void __attribute__((weak)) foo() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/visibility-warning-dylib-v-archive/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo(); 3 | extern void bar(); 4 | 5 | 6 | int main() 7 | { 8 | foo(); 9 | bar(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/visibility-warning/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/visibility-warning/foo_hidden.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void __attribute__((visibility("hidden"))) foo() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/visibility-warning/foo_weak.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void __attribute__((weak)) foo() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/visibility-warning/foo_weak_hidden.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void __attribute__((weak, visibility("hidden"))) foo() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak-def-auto-hide/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void __attribute__((weak)) my_weak() 4 | { 5 | } 6 | 7 | extern void my_other_weak(); 8 | 9 | int main() 10 | { 11 | my_weak(); 12 | my_other_weak(); 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak-def-auto-hide/other.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .text 4 | .align 4 5 | 6 | .globl _my_weak 7 | .weak_def_can_be_hidden _my_weak 8 | _my_weak: nop 9 | nop 10 | 11 | 12 | .globl _my_other_weak 13 | .weak_def_can_be_hidden _my_other_weak 14 | _my_other_weak: nop 15 | nop 16 | 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak-def-flag/main-strip-weak.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // the 'l' prefix makes this an auto-strip symbol 4 | void my_auto_strip_weak() __asm ( "lautostrip" ); 5 | 6 | void __attribute__((weak)) my_auto_strip_weak() 7 | { 8 | 9 | } 10 | 11 | int main() 12 | { 13 | my_auto_strip_weak(); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak-def-flag/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void __attribute__((weak)) my_weak() 4 | { 5 | 6 | } 7 | 8 | int main() 9 | { 10 | my_weak(); 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak-def-hidden-and-global/myglobal.c: -------------------------------------------------------------------------------- 1 | 2 | __attribute__((weak)) 3 | int myweak = 10; 4 | 5 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak-def-ordinal/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int aaa() 3 | { 4 | return 1; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak-def-ordinal/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int __attribute__((weak)) aaa() 3 | { 4 | return 0; 5 | } 6 | 7 | int __attribute__((weak)) bbb() 8 | { 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak-force/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void foo1() {} 4 | void foo3() {} 5 | 6 | 7 | __attribute__((weak)) void foo2() {} 8 | __attribute__((weak)) void foo4() {} 9 | 10 | 11 | void wildcheck() {} 12 | void willnot() {} 13 | 14 | 15 | 16 | __attribute__((weak)) void patterncheck() {} 17 | __attribute__((weak)) void patnot() {} 18 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak-force/foo1.exp: -------------------------------------------------------------------------------- 1 | _foo1 2 | _wild* 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak-force/foo2.exp: -------------------------------------------------------------------------------- 1 | _foo2 2 | _pattern* 3 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_dylib/bar.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "bar.h" 4 | 5 | void bar1() {} 6 | void bar2() {} 7 | void bar3() {} 8 | void bar4() {} 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_dylib/bar.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | extern void bar1(); 4 | extern void bar2() __attribute__((weak_import)); 5 | extern void bar3(); 6 | extern void bar4() __attribute__((weak_import)); 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_dylib/data.c: -------------------------------------------------------------------------------- 1 | 2 | #include "foo.h" 3 | #include "bar.h" 4 | 5 | void* pfoo4 = &foo4; 6 | void* pfoo2 = &foo2; 7 | 8 | void* pbar2 = &bar2; 9 | void* pbar1 = &bar1; // not weak 10 | 11 | int main (void) 12 | { 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_dylib/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "foo.h" 4 | 5 | void foo1() {} 6 | void foo2() {} 7 | void foo3() {} 8 | void foo4() {} 9 | 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_dylib/foo.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | extern void foo1(); 4 | extern void foo2() __attribute__((weak_import)); 5 | extern void foo3(); 6 | extern void foo4() __attribute__((weak_import)); 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_dylib/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include "foo.h" 3 | #include "bar.h" 4 | 5 | void* p; 6 | 7 | int main (void) 8 | { 9 | // non-lazy reference to foo2 10 | p = &foo2; 11 | // lazy reference to foo4 12 | foo4(); 13 | 14 | // non-lazy reference to bar2 15 | p = &bar2; 16 | // lazy reference to bar4 and bar1 17 | bar4(); 18 | bar1(); 19 | 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import-addend/test.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .text 4 | _foo: 5 | #if __x86_64__ 6 | .weak_reference _malloc 7 | .weak_reference _free 8 | cmpq $0, _malloc@GOTPCREL(%rip) 9 | cmpq $0xFFFF, _free@GOTPCREL(%rip) 10 | #endif 11 | nop 12 | 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import-disable/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | void foo() {} 5 | 6 | 7 | #define WEAK_IMPORT_FOR_10_7(sym) \ 8 | extern const char sym##_tmp __asm("$ld$weak$os10.7$_" #sym ); const char sym##_tmp = 0; 9 | 10 | void bar() {} 11 | WEAK_IMPORT_FOR_10_7(bar) 12 | 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import-disable/main.c: -------------------------------------------------------------------------------- 1 | 2 | extern void foo() 3 | #if MAKE_FOO_WEAK_IMPORT 4 | __attribute__((weak_import)) 5 | #endif 6 | ; 7 | 8 | 9 | int main() 10 | { 11 | foo(); 12 | 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import-disable/main2.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | 4 | 5 | 6 | 7 | int main() 8 | { 9 | bar(); 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import-force/bar.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | void bar1() {} 5 | void bar2() {} 6 | 7 | 8 | int bar_data1 = 0; 9 | int bar_data2 = 0; 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import-force/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | void foo1() {} 5 | void foo2() {} 6 | 7 | 8 | int foo_data1 = 0; 9 | int foo_data2 = 0; 10 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import-local/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "foo.h" 4 | 5 | void func2() {} 6 | int data2 = 0; // weak_import initialized 7 | 8 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import-local/foo.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | extern void func2() __attribute__((weak_import)); 4 | 5 | extern int data2 __attribute__((weak_import)); 6 | 7 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import-local/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "foo.h" 4 | 5 | void* pf2 = &func2; 6 | int* pd2 = &data2; 7 | 8 | int main (void) 9 | { 10 | if ( &func2 != NULL ) 11 | func2(); 12 | 13 | if ( &data2 != NULL ) 14 | data2 = 1; 15 | 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import-undefined/weak.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *myweakfunc(void) __attribute__((weak)) ; 4 | 5 | int main(int argc, char **argv) 6 | { 7 | if (myweakfunc) 8 | printf ("found myweakfunc %s\n", myweakfunc()); 9 | else 10 | printf("Weak func not found\n"); 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "foo.h" 4 | 5 | void func1() {} 6 | void func2() {} 7 | void func3() {} 8 | void func4() {} 9 | 10 | 11 | int data1 = 0; 12 | int data2 = 0; // weak_import initialized 13 | int data3; 14 | int data4; // weak_import uninitialized 15 | int data5 = 0; 16 | int data6 = 0; // weak_import 17 | 18 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import/foo.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | extern void func1(); 4 | extern void func2() __attribute__((weak_import)); 5 | extern void func3(); 6 | extern void func4() __attribute__((weak_import)); 7 | 8 | extern int data1; 9 | extern int data2 __attribute__((weak_import)); 10 | extern int data3; 11 | extern int data4 __attribute__((weak_import)); 12 | extern int data5; 13 | extern int data6 __attribute__((weak_import)); 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import2/comment.txt: -------------------------------------------------------------------------------- 1 | Test the weak_import attribute works 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import2/foo.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "foo.h" 4 | 5 | void func1() {} 6 | void func2() {} 7 | void func3() {} 8 | void func4() {} 9 | 10 | 11 | int data1 = 0; 12 | int data2 = 0; // weak_import initialized 13 | int data3; 14 | int data4; // weak_import uninitialized 15 | int data5 = 0; 16 | int data6 = 0; // weak_import 17 | 18 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import2/foo1.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void func2() {} 4 | void func4() {} 5 | 6 | 7 | int data2 = 0; // foo.c also has weak_import initialized 8 | int data4; // foo.c also has weak_import uninitialized 9 | int data6 = 0; // foo.c also has weak_import 10 | 11 | -------------------------------------------------------------------------------- /unit-tests/test-cases/weak_import2/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include "foo.h" 3 | 4 | 5 | int* pdata5 = &data5; 6 | int* pdata6 = &data6; 7 | 8 | 9 | int main (void) 10 | { 11 | // make non-lazy reference to func3 and func4 12 | if ( &func3 == &func4 ) { 13 | // make lazy reference to func3 and func4 14 | func1(); 15 | func2(); 16 | } 17 | 18 | return data1 + data2 + data3 + data4; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /unit-tests/test-cases/why_live/bar.c: -------------------------------------------------------------------------------- 1 | void bar() {} 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/why_live/foo.c: -------------------------------------------------------------------------------- 1 | 2 | extern void bar(); 3 | 4 | void foo() 5 | { 6 | bar(); 7 | } 8 | 9 | void frob() 10 | { 11 | bar(); 12 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/why_live/main.c: -------------------------------------------------------------------------------- 1 | extern void foo(); 2 | 3 | int main() 4 | { 5 | foo(); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /unit-tests/test-cases/zero-fill2/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld can link a program with a large zero-fill section 2 | -------------------------------------------------------------------------------- /unit-tests/test-cases/zero-fill3/comment.txt: -------------------------------------------------------------------------------- 1 | The point of this test is a sanity check that ld can link a program with a large zero-fill section 2 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | if [[ $# -ne 1 ]]; then 6 | echo "usage: $0 URL" >&2 7 | exit 1 8 | fi 9 | 10 | readonly url=$1 11 | 12 | rm -rf ./.gitignore ./APPLE_LICENSE ./compile_stubs ./doc ./ld64.xcodeproj ./src ./unit-tests 13 | curl -L --fail "$url" -o /tmp/ld.tar.gz 14 | tar xf /tmp/ld.tar.gz --strip-components=1 -C . 15 | --------------------------------------------------------------------------------