Producing a MAP (Linker Address Map) when building

285 views
Skip to first unread message

Ryan Skidmore

unread,
Jul 27, 2014, 12:47:19 PM7/27/14
to golan...@googlegroups.com
Hey,

I'm looking for a way to produce a Linker Address Map when building an application in Go - similar to the output of "go tool nm".

In GCC, this is done using the "-Xlinker -Map=output.map" flags.

Any help would be greatly appreciated! :)

- Ryan

Ian Lance Taylor

unread,
Jul 27, 2014, 9:16:08 PM7/27/14
to Ryan Skidmore, golang-nuts
On Sun, Jul 27, 2014 at 9:47 AM, Ryan Skidmore
<ryanskid...@googlemail.com> wrote:
>
> I'm looking for a way to produce a Linker Address Map when building an
> application in Go - similar to the output of "go tool nm".
>
> In GCC, this is done using the "-Xlinker -Map=output.map" flags.

The gc linker does not have this feature.

Ian

ryanskid...@googlemail.com

unread,
Jul 28, 2014, 4:44:36 AM7/28/14
to golan...@googlegroups.com
Thanks Ian.

Do you know if it's possible to link against a COFF/OMF object, and if so, how?

Ryan.

Ian Lance Taylor

unread,
Jul 31, 2014, 11:55:48 PM7/31/14
to Ryan Skidmore, golang-nuts
On Mon, Jul 28, 2014 at 1:44 AM, <ryanskid...@googlemail.com> wrote:
>
> Do you know if it's possible to link against a COFF/OMF object, and if so, how?

COFF and OMF are different formats, so I'm not sure what you are
asking.

The 8l linker does support linking against limited PE/COFF objects
(http://en.wikipedia.org/wiki/Portable_Executable). However, the
usual approach is to have 8l generate a PE/COFF object itself and
invoke an external linker to complete the link. That is how cgo and
SWIG are implemented.

For that matter I suppose you can get your linker map by using
-linkmode external -ldflags "-Xlinker -Map=output.map".

Ian

ryanskid...@googlemail.com

unread,
Aug 1, 2014, 7:43:26 AM8/1/14
to golan...@googlegroups.com, ryanskid...@googlemail.com
Hey Ian,

I attempted to run "go build -linkmode external -ldflags "-Xlinker -Map=output.map"" but unfortunately that didn't work, Go complained about the linkmode parameter not existing.

I'm probably making a really obvious mistake, but if you could point out where i've gone wrong I'd be grateful!

Thanks,
Ryan.

Ian Lance Taylor

unread,
Aug 1, 2014, 9:10:00 AM8/1/14
to Ryan Skidmore, golang-nuts
On Fri, Aug 1, 2014 at 4:43 AM, <ryanskid...@googlemail.com> wrote:
>
> I attempted to run "go build -linkmode external -ldflags "-Xlinker
> -Map=output.map"" but unfortunately that didn't work, Go complained about
> the linkmode parameter not existing.
>
> I'm probably making a really obvious mistake, but if you could point out
> where i've gone wrong I'd be grateful!

Those are linker options, using the go tool you need to use -ldflags.

Ian

> On Friday, 1 August 2014 04:55:48 UTC+1, Ian Lance Taylor wrote:
>>
>> On Mon, Jul 28, 2014 at 1:44 AM, <ryanskid...@googlemail.com> wrote:
>> >
>> > Do you know if it's possible to link against a COFF/OMF object, and if
>> > so, how?
>>
>> COFF and OMF are different formats, so I'm not sure what you are
>> asking.
>>
>> The 8l linker does support linking against limited PE/COFF objects
>> (http://en.wikipedia.org/wiki/Portable_Executable). However, the
>> usual approach is to have 8l generate a PE/COFF object itself and
>> invoke an external linker to complete the link. That is how cgo and
>> SWIG are implemented.
>>
>> For that matter I suppose you can get your linker map by using
>> -linkmode external -ldflags "-Xlinker -Map=output.map".
>>
>> Ian
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages