If you’ve gotten yourself a copy of “Art of Assembly Language” by Randall Hyde, well, good on you. However, if you’re running on a modern version of OSX, you’ve probably run into a snag right out of the gate! It’s never a good sign when Hello World won’t compile, right?
First things first though, you need to have Xcode installed and accept it’s license (‘sudo xcodebuild -license’) - I don’t think this is mentioned in the book or installation instructions (and I don’t think the linker will exist or work otherwise). Get that taken care of, first.
It should go without saying that you need to have downloaded and installed Randall’s HLA. I won’t go into that here, because the book and his website go over that already.
Now, on to the problem. You’ve probably tried to run the helloWorld example and found it didn’t work, right? Something like this?
Undefined symbols for architecture i386:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture i386
Error returned by ld = 256
I’m not sure what’s gone wrong in the first place (apparently this used to work out of the box?) but here’s how to fix it. You need to specify a bunch of arguments to hla to get the linker to do what it’s supposed to be doing. Namely there’s a system library that needs to be linked in, but also a few other things to quiet some silly warnings.
This does a few things:
Well, crap. That’s going to get old, fast. Well… you can always set an alias! We’ll also fix your ‘$PATH’ variable while we’re at it.
If you don’t know what “environment” means in the context of shells, you should probably go read this first. I’m going to assume you know what ‘.bash_profile’, ‘alias’, and ‘$PATH’ are.
if [ -x /usr/hla ]; then
export PATH=${PATH}:/usr/hla
alias hla='hla -main:_main -l"macosx_version_min 10.10" -l"lSystem" -l"no_pie"'
fi
This should be straightforward if you’re at all familiar with bash. If you’re not, go read that beginner’s guide at some point, but for now:
That should be enough to get it working such that you can dive in to the book. Enjoy!
The information, views, and opinions published on this website were done so in the author's personal capacity. The information, views, and opinions expressed in this article are the author's own and do not reflect the view of their employer, or any other entity unless explicitly stated otherwise.
All data and information provided on this site is for informational purposes only. This website and it's operators makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis.
All original content on this website is, unless explicitly stated otherwise, licensed under the MIT license. Full license text is available here. Non-original content that is included on this website in whole or in part, linked, or otherwise made available remains under copyright of the original owners.