func selectMagicNumber(choices: [Int]) -> Int {
return choices[MAGIC_CHOICE]
}
func randomValue() -> Int {
return Int.random(in: 1...100)
}
func numberChoices() -> [Int] {
var choices = [Int]()
for _ in 1...10 {
choices.append(randomValue())
}
return choices
}
func generateMagicNumber() -> Int {
let numbers = numberChoices()
let magic = selectMagicNumber(choices: numbers)
return magic
}
print("The magic number is: \\(generateMagicNumber())")
디버그 정보는 빌드 과정에서 생성된다.
바이너리에 임베딩 될 수 도 있고, 별도 파일로 존재할 수도 있다.
종류
struct nList_64 {
union {
uint32_t n_strx;
}
uint8_t n_type; // 값과 프로퍼티를 결정하는 값
uint8_t n_sect;
uint16_t n_desc;
uint64_t n_value;
}
이 때 이름은 mangle된 상태로 기록된다.
2,3,4번째 LSB가 켜져 있는 상태로 표현
심볼 리스팅
% nm -arch arm64 -defined-only --numeric-sort MagicNumbers | xcrun swift-demangle
% symbols -arch arm64 -onlyNListData MagicNumbers // 자동으로 디맹글링
다만 링킹에 연관된 정보만 있다. 이는 프로젝트 전체적으로 공유되는 컴포넌트, 프레임워크에서 export된 심볼들이 해당한다.
로컬, 정적 함수들은 테이블에서 표현되지 않고, 관련 심볼 정보는 릴리즈모드에서 앱 사이즈 감소등의 이유로 날리는 경우도 있다. → Deployment에 Strip관련 옵션 존재