问题描述
如何在精灵中看到标准c库函数的汇编?例如,我有一个二进制文件,我有这个二进制文件的源代码,我知道在 main 函数中调用了 printf。我想看看这个精灵中printf函数的组装。请注意,我想在 elf 本身中看到程序集。 我搜索了很多,但没有找到任何东西
解决方法
你可以编译
class PractionerListViewController: UIViewController {
@IBOutlet weak var practionerTableView: UITableView!
let searchController = UISearchController(searchResultsController: nil)
var practionerListData = [String]()
var filteredChatUsers: [String] = []
override func viewDidLoad() {
super.viewDidLoad()
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
practionerTableView.tableHeaderView = searchController.searchBar
// getDignosysListFromJson()
load()
}
//MARK: Api request
func getDignosysListFromJson() {
let jsonPath = Bundle.main.path(forResource: "dignosys",ofType: "json")
let jsonUrl = URL(fileURLWithPath: jsonPath!)
do {
let data = try Data(contentsOf: jsonUrl)
let jsonResult = try JSONSerialization.jsonObject(with: data,options: .mutableContainers)
if let newResult = jsonResult as? Array<Dictionary<String,Any>>{
for i in newResult{
let description = i["dx description"] as! String
self.practionerListData.append(description)
print(practionerListData)
}
// uploadDiagnostics(jsonData: newResult)
DispatchQueue.main.async {
print("practioner data count is \(self.practionerListData.count)")
self.practionerTableView.reloadData()
}
}
} catch {
print("")
}
}
}
//MARK: UITableViewDataSource
extension PractionerListViewController: UITableViewDataSource{
func tableView(_ tableView: UITableView,numberOfRowsInSection section: Int) -> Int {
if practionerListData.count == 0{
// tableView.setEmptyView(title: "You can chat with your Kismet here.",message: "",alertimage: "NewChat")
searchController.searchBar.isHidden = true
}
else{
searchController.searchBar.isHidden = false
tableView.restore()
}
if searchController.isActive && searchController.searchBar.text != "" {
if filteredChatUsers.count == 0{
// tableView.setEmptyView(title: "Invalid Search. Try Again",alertimage: "NewChat")
}
else{
tableView.restore()
}
return filteredChatUsers.count
} else {
return practionerListData.count
}
//
// return practionerListData.count ?? 0
}
func tableView(_ tableView: UITableView,cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "PractionerListTableViewCell") as? PractionerListTableViewCell else {
return UITableViewCell()
}
cell.textLabel?.text = practionerListData[indexPath.row]
return cell
}
}
//MARK: UITableViewDelegate
extension PractionerListViewController: UITableViewDelegate{
func tableView(_ tableView: UITableView,didSelectRowAt indexPath: IndexPath) {
print("dignosysdata at index is \(practionerListData[indexPath.row])")
let dignosysData:[String: String] = ["dignose": "\(practionerListData[indexPath.row])"]
// post a notification
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "notificationName"),object: nil,userInfo: dignosysData)
// self.navigationController?.popViewController(animated: true)
self.dismiss(animated: true,completion: nil)
}
}
//MARK:- SearchViewController Delegate
extension PractionerListViewController: UISearchResultsUpdating{
func updateSearchResults(for searchController: UISearchController) {
filterContentForSearchText(searchText: searchController.searchBar.text!)
}
func filterContentForSearchText(searchText: String) {
filteredChatUsers = practionerListData.filter({ (user) -> Bool in
return user.lowercased().contains(searchText.lowercased())
})
practionerTableView.reloadData()
}
}
extension PractionerListViewController: NSFetchedResultsControllerDelegate {
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
practionerTableView.beginUpdates()
}
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>,didChange anObject: Any,at indexPath: IndexPath?,for type: NSFetchedResultsChangeType,newIndexPath: IndexPath?) {
guard let indexPath = indexPath else { return }
switch type {
case .update:
practionerTableView.reloadRows(at: [indexPath],with: .fade)
case .delete:
practionerTableView.deleteRows(at: [indexPath],with: .fade)
default:
break
}
}
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
practionerTableView.endUpdates()
}
// MARK: - Private
func load() {
let data = CoreDataStack()
let moc = data.persistentContainer.viewContext
let sortByName = NSSortDescriptor(key: "name",ascending: true)
let sortDescriptors = [sortByName]
let request: NSFetchRequest<Dignose> = Dignose.fetchRequest()
request.sortDescriptors = sortDescriptors
do {
let students = try moc.fetch(request)
for i in students {
self.practionerListData.append(i.name!)
}
DispatchQueue.main.async {
print("practioner data count is \(self.practionerListData.count)")
self.practionerTableView.reloadData()
}
}
catch let error as NSError {
print("Error fetching students: \(error.localizedDescription)")
}
}
}
而 ~$ gcc -static prog.c
使用您组装的函数。
这将静态链接用于二进制文件的库。
然后你可以:
prog.c
编辑
您甚至可以采用更简单的方法:
只是 ~$ objdump --disassemble a.out
libc 库:
objdump