Relative References in ARM64 Disassembly

POV: You are a compiler targeting arm641, and you want some code to reference this global variable from the same library. The classic way to do this is to emit an instruction that loads “the address of X”, which will be determined at run time by the dynamic loader. But that’s not super efficient! For one thing, addresses are 64 bits long, and instructions are only 32 bits, so you can either break it up into multiple instructions, or load the address from some other location. But more importantly, the global variable is in the same library. The dynamic loader isn’t going to break it up from this code2, and if we knew how far away it was we could reference it that way.

That’s what the adrp instruction’s for.

Default Arguments and Label-based Overloading

This post is in response to Aria Beingessner’s “Defaults Affect Inference in Rust: Expressions Instead Of Types”, which describes how adding default arguments to Rust could help with some Rust stdlib problems around generics. At the same time, the Rust internals forum has a thread on “Named Arguments” something that’s been discussed for Rust off and on for years (at varying levels of seriousness).

Here I’m going to discuss how those two features interact, and why considering them separately is potentially a bad idea. It’s a lot more braindump-y than my usual style, so be warned. The post is written with a Rust audience in mind, but makes frequent reference to Swift, Python, and C# as examples of real-world languages that have some version of these features. It also overlaps quite a bit with Aria’s post.

#TalkPay

In the general interest of pay transparency, here’s a table showing how much I made at Apple (a Big Company that’s nonetheless not known for particularly high compensation in the tech industry), vs Signal (a nonprofit that nonetheless understands that it has to be in Tech Salary Range to be competitive).

(Why “#TalkPay”? It’s a Twitter hashtag that seems to have originally come from 2013’s conversation around the gender wage gap…but I first heard it in the context of openly sharing your name, location, role, and salary, so that others in similar positions could check if they were being paid a fair amount. Lauren Voswinkel, who put out the original call for action in 2015, has a good rundown.)

Older Posts

  1. 2022-02-21 Dynamic Linking Is Bad For Apps And Static Linking Is Also Bad For Apps
  2. 2021-12-31 Swift Regrets: Wrap-up
  3. 2021-09-10 Swift Regrets
  4. 2021-07-05 Keyboard Pants
  5. 2020-11-15 Negotiate Your Offers!
  6. 2020-10-20 The Swift Runtime: Enums
  7. 2020-10-06 The Swift Runtime: Class Metadata Initialization
  8. 2020-09-29 The Swift Runtime: Class Metadata
  9. 2020-09-21 The Swift Runtime: Uniquing Caches
  10. 2020-09-14 The Swift Runtime: Type Metadata
  11. 2020-09-07 The Swift Runtime: Type Layout
  12. 2020-08-31 The Swift Runtime: Heap Objects
  13. 2020-08-26 Objective-Rust
  14. 2020-07-18 A Letter To My Congressional Representatives on the DHS Abuses of Power in Portland, Oregon
  15. 2020-07-07 Suffusion: Playing with Filesystems
  16. 2020-05-24 ROSE-8 on Mac OS 9
  17. 2020-04-03 Shallow Git Repositories
  18. 2020-04-01 Swift on Mac OS 9
  19. 2020-02-06 Flexible Identities in git
  20. 2020-02-04 Introducing the Game 'by Color
  21. 2020-01-28 ROSE-8: Console Mode
  22. 2020-01-22 Setting up gitweb on Shared Hosting
  23. 2020-01-13 ROSE-8
  24. 2019-12-24 quasiquarantine
  25. 2019-11-01 Leaving Apple
  26. 2019-08-01 > go east
  27. 2018-04-29 Misleading Metrics and UX Tradeoffs
  28. 2018-04-03 "FIXME" Doesn't Always Mean "Fix Me"
  29. 2018-03-22 My Little (String) Optimization, Part 2
  30. 2018-03-15 My Little Optimization: The Compiler Is Magic
  31. 2018-02-26 Many-to-Many Protocols
  32. 2018-01-29 Color Palette #8
  33. 2017-09-07 The New Kingdom of Nouns
  34. 2017-09-05 Over-abstraction
  35. 2016-08-21 Macromancy, Part 2
  36. 2016-08-07 Macromancy
  37. 2016-06-19 Pronoun Buttons
  38. 2016-05-29 Webmailer's Update Bar
  39. 2016-05-23 So You Want to Be a (Compiler) Wizard
  40. 2015-12-29 Re: Contempt Culture
  41. 2015-11-18 Recommendations
  42. 2015-05-09 Nibblesort: Adventures in Optimization
  43. 2015-02-22 AlterConf SF/Oakland
  44. 2015-01-24 “Skip the FFI”
  45. 2012-12-08 How to Write a Checker in 24 Hours
  46. 2012-10-02 Git Tricks
  47. 2012-05-16 Big News
  48. 2012-04-26 Keyboard Adventures
  49. 2012-04-10 Mail Aliases
  50. 2011-08-14 Header Anchors: A Safari Extension
  51. 2011-08-10 "Little Big Details"
  52. 2011-07-29 Weak Linking
  53. 2011-07-25 Using Clang from SVN in Xcode
  54. 2011-07-22 rm vs. Time Machine
  55. 2011-07-14 Priorities
  56. 2011-06-30 Quick Look in TextMate
  57. 2011-06-27 git add
  58. 2011-06-20 Automatic Reference Counting
  59. 2011-06-16 Dealing with "Sandwich Code"
  60. 2011-06-05 gdba
  61. 2011-06-03 Chrome vs. Safari
  62. 2011-05-31 User-Side Troubleshooting
  63. 2011-05-30 Auspicious Continuation
  64. 2009-07-21 Scripting Bridge
  65. 2009-07-08 What Happened to Dockyard?
  66. 2009-06-26 Garbage Collectors and Stack Drawers
  67. 2009-06-21 Z shell
  68. 2009-05-22 “Several New Features”
  69. 2009-05-05 C++ Templates are Turing-Complete
  70. 2009-04-21 [Meme] How Many HTML Elements Can You Name in 5 Minutes?
  71. 2009-04-16 Safer Plugin Categories
  72. 2009-04-02 Hacking Safari 4...for Great Convenience
  73. 2009-03-27 Const Correctness
  74. 2009-03-19 Categories and +load
  75. 2009-03-15 Subversion Checksum Problems
  76. 2009-03-06 JavaScript Tetris
  77. 2008-09-04 Objective-J and Objective-C
  78. 2008-08-28 HTTPS and Name-based Virtual Hosting
  79. 2008-03-08 Alerts Without Apps (or nibs)
  80. 2008-01-14 NSNumber, CFNumber, and CFBoolean
  81. 2007-12-13 GenericToolbar and IB3
  82. 2007-10-27 Performance Optimization: Why We Can't Use valueForKeyPath:
  83. 2007-09-01 Short Xcode Tip: Plugins
  84. 2007-07-15 Port 25 Blocked?
  85. 2007-06-27 GenericToolbar Icon
  86. 2007-04-13 The Symbolism of Pretty URLS
  87. 2007-03-07 Flexible PHP
  88. 2007-01-12 Inauspicious Beginnings