Parsing the cause of program crash and Program Calling process below 3gs

Source: Internet
Author: User

 

Symptom description:

Program crash

 

Error Log information:

 

Error cause:

The compiled version options of the introduced library are inconsistent with those of the project, for example

Compilation Option 1

And

Compilation Option 2

The options selected for compilation are inconsistent. As a result, the program compiled by standar armv6 supports versions earlier than 3gs hardware, but the library selects optimized (armv7) the executable program compiled by the compiled library in the project only supports the hardware version above 3gs (because the hardware above 3gs already uses the armv7 command)

 

 

**********************************

Troubleshooting steps

****************************************

1,

When we first encountered this problem, the first response was whether it was an error in the compilation of high and low versions on different machine subtypes. Therefore, the issue was executed directly on the terminal side.

For example,./XXX (if an error occurs in the framework reference, the related framework issue description will be prompted after running)

In addition, you can install otool (in cydia link indenty Editor, after installation is complete, the default path is/usr/bin) and directly execute such as otool-l XXX (Execution file) on the terminal) to obtain the list of shared libraries that executable files depend on.

 

However, the above display and framework are all correct.

 

2,

View the crash log

According to figure 3, the final execution location of the program crash is in the imageloadermacho: doinitialization () function, and the program call is not started yet, so I guess it may crash when loading the dynamic library.

Because when links generate executable programs, there is a dynamic library in the Dynamic Link project. The dynamic library feature is not to link the target files that constitute the program, the link will not be established until the program is running. That is to say, the link process is postponed until the runtime.

In this way, the link to the dynamic library in the project is slowly deleted, but unfortunately the compiled executable program still cannot be run on the real machine.

 

*******************

According to the error imageloadermacho

Mach-O is short for the Mach object file format. It is a file format used for executable files, target code, dynamic libraries, and kernel dump. As an alternative to the. Out format, Mach-O provides higher scalability and improves the access speed of information in the symbol table.

Mach-O was used by most operating systems based on Mach (micro operating systems, Mac OS also use Mach-derived systems.

Http://zh.wikipedia.org/wiki/Mach-O

 

Dyld

Mac OS X supports multiple runtime environments at the initial release. Currently, the environment of active projects is dyld. Other environments are only used for porting Mac OS 9 to Mac OS X. The dyld environment is the local Mac OS X environment that reads, links, and executes the Mach-o file. Its core is the dynamic loader called dyld ). It processes the reading of programs and dynamic libraries, parses dependencies between libraries and modules, and executes programs.

When reading the program code module, the dynamic loader executes the smallest symbol binding to execute your program. The binding process includes parsing external libraries and loading them when they are used. The symbol is strongly or weak. The difference between them is that a strong link terminates a program when the symbols in the library cannot be found or the library cannot be found. The weak link does not exist in the use of symbols and is used to terminate the program.

 

3,

Because the program still cannot be started after the dynamic library is deleted, it should be a static Link error (the floating number of the armv compilation command that appears to be compiled from 3gs and used is upgraded from armv6 ---> armv7) in this case, will the static library be compiled into armv7.

After the static libraries used in the program are re-compiled, the hardware of 3gs and touch2 generation may be supported.

 

 

**************************************** **********************************

The entire process of iPhone program compilation and running is summarized from the above phenomena.

First, xcode

Pre-compile: This process processes macro definition and include, and performs syntax check.

Compile: Generate assembly code

Assembly: generate the target code

Link process: generate executable code. links are divided into static and dynamic links,

Where

The static link is used to add the content of the static library to the executable program during the link. (The disadvantage is that the generated executable program is too large to consume more time when loading the memory)

Dynamic Links are used to link the target files when the program runs.

 

When the program generates executable programs on Mac OS, such as X, and then put them on the iPhone

First, before entering the main function of X, the program

The dynamic loader dyld will load the dynamic library linked to the program and the dynamic library required for running the program. It will also read information such as the weak or strong link of the framework, weak is that a strong link terminates a program when the symbols in the library cannot be found or the library cannot be found. The weak link does not exist in the use of symbols and is used to terminate the program.

 

After loading the external Shared Library and other information, the main function of the program will be called.

**************************************** **********************

Because Mac OS compiled executable programs are all macn-o file types

For more information about the organizational structure of executable program files, see

Http://2009fly.com/index/a/yidongkaifa/iPhone/rumen/iPhonegaoji/2011/0228/603.html

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.