avo icon indicating copy to clipboard operation
avo copied to clipboard

operand,build: support external package symbols

Open mmcloughlin opened this issue 5 years ago • 3 comments

Add support for referencing symbols in other packages. Include an example of calling an external function or (potentially easier) reading a variable from another package.

Related: #39

mmcloughlin avatar Jan 07 '19 04:01 mmcloughlin

Onur has expressed interest on this feature on Twitter: https://twitter.com/onkkil/status/1145041747979964416.

As a workaround, it should be possible to use NewDataAddr. You'll just have to include the annoying unicode dot yourself. So something like the following would give the reference you want.

xyz := operand.NewDataAddr(Symbol{Name: "·xyz"}, 0)

I'd like to provide a cleaner interface for this, but I hope this works for now?

mmcloughlin avatar Jun 29 '19 22:06 mmcloughlin

Thanks, it works as expected. Here is a little example.

xyz := operand.NewDataAddr(Symbol{Name: "·xyz"}, 0)
MOVQ(xyz.Offset(8), reg.R8)

kilic avatar Jun 30 '19 17:06 kilic

Great, glad that worked!

mmcloughlin avatar Jul 01 '19 18:07 mmcloughlin