0

after using the below command i am getting the two flags as "binds_to_weak" and "weak_defines". what is their significance?

$ otool -hv

(architecture armv7): Mach header magic cputype cpusubtype caps filetype ncmds sizeofcmds flags MH_MAGIC ARM V7 0x00 EXECUTE 38 4292 NOUNDEFS DYLDLINK TWOLEVEL WEAK_DEFINES BINDS_TO_WEAK PIE

1 Answers1

0

MH_WEAK_DEFINES means that an executable has a weak symbol. Weak symbols are a linker trick to avoid linking in supporting code which isn't used. For example, the compiler does its analysis and determines that the application is integer only and tells the linker to not link in floating point support code. From the Oracle® Solaris 11.4 Linkers and Libraries Guide (which is not talking about Mach-O):

Historically, weak symbols have been used to circumvent interposition, or test for optional functionality. However, experience has shown that weak symbols are fragile and unreliable in modern programming environments, and their use is discouraged.

This is explained better in Chapter 6 of John Levine's Linkers and Loaders.

Olsonist
  • 2,051
  • 1
  • 20
  • 35