FAQ
Hi,

I have implemented two new flags (-cumsize and -pkgsize) for /cmd/nm

The output looks like:


  $ go tool nm *-*size -sort size ./foo

   5c32e0 637567 r runtime.pclntab
   681b20 65688 D runtime.trace
   500d90 17520 T unicode.init
   67dc60 16064 D runtime.semtable
   4c55f0 13984 T time.parse
   46af40 12992 T fmt.(*pp).printReflectValue
   67ab20 12584 D runtime.mheap_
   48e4e0 10144 T crypto/sha256.block
   4c28b0 9440 T time.Time.AppendFormat
   6955e0 8192 D runtime.pdesc
   678b80 8072 D runtime.hash
(More entries below are omitted)

  $ go tool nm* -*size *-cumsize* -sort size ./foo

   5c32e0 637567 637567 r runtime.pclntab
   681b20 65688 703255 D runtime.trace
   500d90 17520 720775 T unicode.init
   67dc60 16064 736839 D runtime.semtable
   4c55f0 13984 750823 T time.parse
   46af40 12992 763815 T fmt.(*pp).printReflectValue
   67ab20 12584 776399 D runtime.mheap_
   48e4e0 10144 786543 T crypto/sha256.block
   4c28b0 9440 795983 T time.Time.AppendFormat
   6955e0 8192 804175 D runtime.pdesc
   678b80 8072 812247 D runtime.hash
(More entries below are omitted)

`$ go tool nm -pkgsize ./foo` will add a table at the bottom:

Contributions of size per package:

runtime 1057005
sync/atomic 504
x_cgo_mmap 45
x_cgo_threadentry 8
bufio 8049
hash 65
runtime/debug 832
runtime/cgo 1446
internal/singleflight 65
io 1793
sync 5649
x_cgo_inittls 8
fatalf 206


I wrote this for figuring out why my programs are so huge, and hopefully
being able to replace some heavy weight dependencies with simplified ones.
(Those programs need to be transmitted over serial ports and probably
telephone lines so size matters.)
The modification is pretty straightforward. If it is useful for others and
compatible with the purpose of /cmd/nm, I will submit it for review.

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Lucio De Re at Mar 16, 2016 at 5:59 am
    I can only speak for myself, but something as inevitable (and useful)
    as this deserves serious consideration.

    Lucio.
    On 3/16/16, mura wrote:
    Hi,

    I have implemented two new flags (-cumsize and -pkgsize) for /cmd/nm
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Minux at Mar 16, 2016 at 7:05 am

    On Wed, Mar 16, 2016 at 1:54 AM, mura wrote:

    Hi,

    I have implemented two new flags (-cumsize and -pkgsize) for /cmd/nm

    `$ go tool nm -pkgsize ./foo` will add a table at the bottom:

    Contributions of size per package:

    runtime 1057005
    sync/atomic 504
    x_cgo_mmap 45
    x_cgo_threadentry 8
    bufio 8049
    hash 65
    runtime/debug 832
    runtime/cgo 1446
    internal/singleflight 65
    io 1793
    sync 5649
    x_cgo_inittls 8
    fatalf 206
    You might to add a category "internal runtime" for symbols that
    doesn't contain a dot in their name (e.g. x_cgo_inittls, x_cgo_mmap, ...)

    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Mura at Mar 16, 2016 at 8:29 am
    Alright.

    It looks like this now:


    Contributions of size per package:

    [Internal runtime]
    _cgo_notify_runtime_init_done 8
    _cgo_thread_start 8
    _cgo_topofstack 32
    gosave 48
    _cgo_sys_thread_start 214
    x_cgo_sys_thread_create 75
    masks 256
    runtime_init_cond 48
    _cgo_mmap 8
    fatalf 206
    setg_gcc 24
    x_cgo_setenv 17
    _rt0_amd64_linux 32
    shifts 256
    x_cgo_inittls 8
    _cgo_malloc 8
    runtime_init_done 4
    runtime_init_mu 40
    x_cgo_free 8
    _cgo_free 8
    _cgo_init 8
    _cgo_panic 48
    main 16
    x_cgo_mmap 45
    x_cgo_threadentry 8
    x_cgo_thread_start 87
    x_cgo_unsetenv 5
    _cgo_wait_runtime_init_done 77
    crosscall2 80
    threadentry 68
    x_cgo_init 143
    x_cgo_malloc 61
    x_cgo_notify_runtime_init_done 54

    [Packages]
    encoding/binary 305
    encoding/csv 5601
    flag 19081
    github 120467
    reflect 101069
    text/template 85746
    bufio 8049
    crypto/des 7241
    hash 65
    internal/singleflight 65
    math 2818
    my/crypto/rsa 2660
    os 17633
    syscall 24154
    unicode 77071
    unicode/utf8 3514
    cap 14153
    errors 224
    math/rand 13729
    sync 5649
    time 81184
    crypto 1761
    net 58352
    strings 14889
    sync/atomic 504
    $f64 392
    crypto/rand 2926
    path/filepath 10129
    runtime/cgo( 1446
    runtime/internal/atomic 448
    $f32 20
    crypto/sha256 13021
    main 10258
    runtime 1056982
    bytes 7785
    go 2176
    math/big 78009
    my/crypto/cipher 1216
    runtime/debug 832


    Another approach is to add a new column or "mark" to indicate the special
    ones, which would probably be more awk-friendly (but less
    human-eyes-friendly).
    On Wednesday, March 16, 2016 at 3:05:13 PM UTC+8, minux wrote:



    On Wed, Mar 16, 2016 at 1:54 AM, mura <aruma...@gmail.com <javascript:>>
    wrote:
    Hi,

    I have implemented two new flags (-cumsize and -pkgsize) for /cmd/nm

    `$ go tool nm -pkgsize ./foo` will add a table at the bottom:

    Contributions of size per package:

    runtime 1057005
    sync/atomic 504
    x_cgo_mmap 45
    x_cgo_threadentry 8
    bufio 8049
    hash 65
    runtime/debug 832
    runtime/cgo 1446
    internal/singleflight 65
    io 1793
    sync 5649
    x_cgo_inittls 8
    fatalf 206
    You might to add a category "internal runtime" for symbols that
    doesn't contain a dot in their name (e.g. x_cgo_inittls, x_cgo_mmap, ...)
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Minux at Mar 16, 2016 at 8:33 am

    On Wed, Mar 16, 2016 at 4:29 AM, mura wrote:

    Alright.

    It looks like this now:
    Sorry, I wasn't clear. My suggestion is to collect all those symbols
    without dots
    in their name into one entry "internal runtime" (or you can just put them
    into
    package "runtime".)
    Contributions of size per package:

    [Internal runtime]
    _cgo_notify_runtime_init_done 8
    _cgo_thread_start 8
    _cgo_topofstack 32
    gosave 48
    _cgo_sys_thread_start 214
    x_cgo_sys_thread_create 75
    masks 256
    runtime_init_cond 48
    _cgo_mmap 8
    fatalf 206
    setg_gcc 24
    x_cgo_setenv 17
    _rt0_amd64_linux 32
    shifts 256
    x_cgo_inittls 8
    _cgo_malloc 8
    runtime_init_done 4
    runtime_init_mu 40
    x_cgo_free 8
    _cgo_free 8
    _cgo_init 8
    _cgo_panic 48
    main 16
    x_cgo_mmap 45
    x_cgo_threadentry 8
    x_cgo_thread_start 87
    x_cgo_unsetenv 5
    _cgo_wait_runtime_init_done 77
    crosscall2 80
    threadentry 68
    x_cgo_init 143
    x_cgo_malloc 61
    x_cgo_notify_runtime_init_done 54

    [Packages]
    encoding/binary 305
    encoding/csv 5601
    flag 19081
    github 120467
    reflect 101069
    text/template 85746
    bufio 8049
    crypto/des 7241
    hash 65
    internal/singleflight 65
    math 2818
    my/crypto/rsa 2660
    os 17633
    syscall 24154
    unicode 77071
    unicode/utf8 3514
    cap 14153
    errors 224
    math/rand 13729
    sync 5649
    time 81184
    crypto 1761
    net 58352
    strings 14889
    sync/atomic 504
    $f64 392
    crypto/rand 2926
    path/filepath 10129
    runtime/cgo( 1446
    runtime/internal/atomic 448
    $f32 20
    crypto/sha256 13021
    main 10258
    runtime 1056982
    bytes 7785
    go 2176
    math/big 78009
    my/crypto/cipher 1216
    runtime/debug 832


    Another approach is to add a new column or "mark" to indicate the special
    ones, which would probably be more awk-friendly (but less
    human-eyes-friendly).
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Arumakanil at Mar 16, 2016 at 8:43 am
    OK, I got it. They were just simple changes.


    It should look like this now:
    Contributions of size per package:

    runtime/cgo 1446
    internal runtime 2008
    crypto/rand 2926
    errors 224
    github 120467
    main 10258
    math 2818
    runtime 1056982
    sync 5649
    crypto 1761
    crypto/rsa 2052
    encoding/binary 305
    go 2176
    my/crypto/cipher 1216
    my/crypto/rsa 2660
    sort 6640
    hash 65
    reflect 101069
    runtime/internal/atomic 448
    syscall 24154
    bytes 7785
    crypto/des 7241
    path/filepath 10129
    $f64 392
    flag 19081
    os 17633
    sync/atomic 504
    text/template 85746
    $f32 20
    bufio 8049
    crypto/aes 258
    crypto/cipher 193
    fmt 74913
    unicode/utf8 3514
    crypto/sha256 13021
    net 58352
    runtime/debug 832
    strconv 51092
    time 81184
    unicode 77071
    math/rand 13729
    cap 14153
    encoding/csv 5601

    The "internal runtime" entry uses the same map along with others so its
    order isn't prioritized over others either (maybe it should?).
    If that matters, I can put it at the first row or give it special emphasis.
    On Wednesday, March 16, 2016 at 4:33:30 PM UTC+8, minux wrote:



    On Wed, Mar 16, 2016 at 4:29 AM, mura <aruma...@gmail.com <javascript:>>
    wrote:
    Alright.

    It looks like this now:
    Sorry, I wasn't clear. My suggestion is to collect all those symbols
    without dots
    in their name into one entry "internal runtime" (or you can just put them
    into
    package "runtime".)
    Contributions of size per package:

    [Internal runtime]
    _cgo_notify_runtime_init_done 8
    _cgo_thread_start 8
    _cgo_topofstack 32
    gosave 48
    _cgo_sys_thread_start 214
    x_cgo_sys_thread_create 75
    masks 256
    runtime_init_cond 48
    _cgo_mmap 8
    fatalf 206
    setg_gcc 24
    x_cgo_setenv 17
    _rt0_amd64_linux 32
    shifts 256
    x_cgo_inittls 8
    _cgo_malloc 8
    runtime_init_done 4
    runtime_init_mu 40
    x_cgo_free 8
    _cgo_free 8
    _cgo_init 8
    _cgo_panic 48
    main 16
    x_cgo_mmap 45
    x_cgo_threadentry 8
    x_cgo_thread_start 87
    x_cgo_unsetenv 5
    _cgo_wait_runtime_init_done 77
    crosscall2 80
    threadentry 68
    x_cgo_init 143
    x_cgo_malloc 61
    x_cgo_notify_runtime_init_done 54

    [Packages]
    encoding/binary 305
    encoding/csv 5601
    flag 19081
    github 120467
    reflect 101069
    text/template 85746
    bufio 8049
    crypto/des 7241
    hash 65
    internal/singleflight 65
    math 2818
    my/crypto/rsa 2660
    os 17633
    syscall 24154
    unicode 77071
    unicode/utf8 3514
    cap 14153
    errors 224
    math/rand 13729
    sync 5649
    time 81184
    crypto 1761
    net 58352
    strings 14889
    sync/atomic 504
    $f64 392
    crypto/rand 2926
    path/filepath 10129
    runtime/cgo( 1446
    runtime/internal/atomic 448
    $f32 20
    crypto/sha256 13021
    main 10258
    runtime 1056982
    bytes 7785
    go 2176
    math/big 78009
    my/crypto/cipher 1216
    runtime/debug 832


    Another approach is to add a new column or "mark" to indicate the special
    ones, which would probably be more awk-friendly (but less
    human-eyes-friendly).
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Austin Clements at Mar 16, 2016 at 3:19 pm
    I'm not entirely sure this belongs in nm, but the package size information
    does seem useful.

    I'm less sure of the utility of -cumsize. What's the intended use case?

    I wouldn't label symbols without a package as "internal runtime". If you
    want to give them a package, they should just be in runtime, since the fact
    that they don't have a package separator is an implementation detail.
    However, go tool nm works just fine on non-Go binaries, or binaries that
    are a mix of Go and non-Go. In this case, I would expect there to be a
    large number of symbols without a package that aren't runtime symbols. So I
    would just label these as package "(none)". (That's also more awk-friendly
    than "internal runtime" :)
    On Wed, Mar 16, 2016 at 4:43 AM, wrote:

    OK, I got it. They were just simple changes.


    It should look like this now:
    Contributions of size per package:

    runtime/cgo 1446
    internal runtime 2008
    crypto/rand 2926
    errors 224
    github 120467
    main 10258
    math 2818
    runtime 1056982
    sync 5649
    crypto 1761
    crypto/rsa 2052
    encoding/binary 305
    go 2176
    my/crypto/cipher 1216
    my/crypto/rsa 2660
    sort 6640
    hash 65
    reflect 101069
    runtime/internal/atomic 448
    syscall 24154
    bytes 7785
    crypto/des 7241
    path/filepath 10129
    $f64 392
    flag 19081
    os 17633
    sync/atomic 504
    text/template 85746
    $f32 20
    bufio 8049
    crypto/aes 258
    crypto/cipher 193
    fmt 74913
    unicode/utf8 3514
    crypto/sha256 13021
    net 58352
    runtime/debug 832
    strconv 51092
    time 81184
    unicode 77071
    math/rand 13729
    cap 14153
    encoding/csv 5601

    The "internal runtime" entry uses the same map along with others so its
    order isn't prioritized over others either (maybe it should?).
    If that matters, I can put it at the first row or give it special emphasis.
    On Wednesday, March 16, 2016 at 4:33:30 PM UTC+8, minux wrote:


    On Wed, Mar 16, 2016 at 4:29 AM, mura wrote:

    Alright.

    It looks like this now:
    Sorry, I wasn't clear. My suggestion is to collect all those symbols
    without dots
    in their name into one entry "internal runtime" (or you can just put them
    into
    package "runtime".)
    Contributions of size per package:

    [Internal runtime]
    _cgo_notify_runtime_init_done 8
    _cgo_thread_start 8
    _cgo_topofstack 32
    gosave 48
    _cgo_sys_thread_start 214
    x_cgo_sys_thread_create 75
    masks 256
    runtime_init_cond 48
    _cgo_mmap 8
    fatalf 206
    setg_gcc 24
    x_cgo_setenv 17
    _rt0_amd64_linux 32
    shifts 256
    x_cgo_inittls 8
    _cgo_malloc 8
    runtime_init_done 4
    runtime_init_mu 40
    x_cgo_free 8
    _cgo_free 8
    _cgo_init 8
    _cgo_panic 48
    main 16
    x_cgo_mmap 45
    x_cgo_threadentry 8
    x_cgo_thread_start 87
    x_cgo_unsetenv 5
    _cgo_wait_runtime_init_done 77
    crosscall2 80
    threadentry 68
    x_cgo_init 143
    x_cgo_malloc 61
    x_cgo_notify_runtime_init_done 54

    [Packages]
    encoding/binary 305
    encoding/csv 5601
    flag 19081
    github 120467
    reflect 101069
    text/template 85746
    bufio 8049
    crypto/des 7241
    hash 65
    internal/singleflight 65
    math 2818
    my/crypto/rsa 2660
    os 17633
    syscall 24154
    unicode 77071
    unicode/utf8 3514
    cap 14153
    errors 224
    math/rand 13729
    sync 5649
    time 81184
    crypto 1761
    net 58352
    strings 14889
    sync/atomic 504
    $f64 392
    crypto/rand 2926
    path/filepath 10129
    runtime/cgo( 1446
    runtime/internal/atomic 448
    $f32 20
    crypto/sha256 13021
    main 10258
    runtime 1056982
    bytes 7785
    go 2176
    math/big 78009
    my/crypto/cipher 1216
    runtime/debug 832


    Another approach is to add a new column or "mark" to indicate the
    special ones, which would probably be more awk-friendly (but less
    human-eyes-friendly).
    --
    You received this message because you are subscribed to the Google Groups
    "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Mura at Mar 17, 2016 at 2:45 am

    On Wednesday, March 16, 2016 at 11:19:09 PM UTC+8, Austin Clements wrote:
    I'm not entirely sure this belongs in nm, but the package size information
    does seem useful.
    I'm less sure of the utility of -cumsize. What's the intended use case?
      I am starting to be inclined to implement it in another independent tool
    (or just a shell script wrapping nm to do the trick) for my personal use.
    People have established expectations about what nm is supposed to do and
    the notion 'package' is specific to Go so it might be better to keep nm as
    it is. It's still debatable.

      It would be more convincing to be built in the toolchain if dependency
    analysis (size-wise or not) is going to be a good practice in development
    workflow. I have yet to form my opinion about that though, as I do this
    only because the size issue becomes obvious to me .

    Regarding -cumesize, it's less useful than I thought at first after I had
    the info of -pkgsize. I just wanted to have a rough estimation of the best
    hope that my program's size could be without adding the numbers manually.

    I wouldn't label symbols without a package as "internal runtime". If you
    want to give them a package, they should just be in runtime, since the fact
    that they don't have a package separator is an implementation detail.
    However, go tool nm works just fine on non-Go binaries, or binaries that
    are a mix of Go and non-Go. In this case, I would expect there to be a
    large number of symbols without a package that aren't runtime symbols. So I
    would just label these as package "(none)". (That's also more awk-friendly
    than "internal runtime" :)

    Agreed.


    On Wed, Mar 16, 2016 at 4:43 AM, <aruma...@gmail.com <javascript:>> wrote:

    OK, I got it. They were just simple changes.


    It should look like this now:
    Contributions of size per package:

    runtime/cgo 1446
    internal runtime 2008
    crypto/rand 2926
    errors 224
    github 120467
    main 10258
    math 2818
    runtime 1056982
    sync 5649
    crypto 1761
    crypto/rsa 2052
    encoding/binary 305
    go 2176
    my/crypto/cipher 1216
    my/crypto/rsa 2660
    sort 6640
    hash 65
    reflect 101069
    runtime/internal/atomic 448
    syscall 24154
    bytes 7785
    crypto/des 7241
    path/filepath 10129
    $f64 392
    flag 19081
    os 17633
    sync/atomic 504
    text/template 85746
    $f32 20
    bufio 8049
    crypto/aes 258
    crypto/cipher 193
    fmt 74913
    unicode/utf8 3514
    crypto/sha256 13021
    net 58352
    runtime/debug 832
    strconv 51092
    time 81184
    unicode 77071
    math/rand 13729
    cap 14153
    encoding/csv 5601

    The "internal runtime" entry uses the same map along with others so its
    order isn't prioritized over others either (maybe it should?).
    If that matters, I can put it at the first row or give it special
    emphasis.
    On Wednesday, March 16, 2016 at 4:33:30 PM UTC+8, minux wrote:


    On Wed, Mar 16, 2016 at 4:29 AM, mura wrote:

    Alright.

    It looks like this now:
    Sorry, I wasn't clear. My suggestion is to collect all those symbols
    without dots
    in their name into one entry "internal runtime" (or you can just put
    them into
    package "runtime".)
    Contributions of size per package:

    [Internal runtime]
    _cgo_notify_runtime_init_done 8
    _cgo_thread_start 8
    _cgo_topofstack 32
    gosave 48
    _cgo_sys_thread_start 214
    x_cgo_sys_thread_create 75
    masks 256
    runtime_init_cond 48
    _cgo_mmap 8
    fatalf 206
    setg_gcc 24
    x_cgo_setenv 17
    _rt0_amd64_linux 32
    shifts 256
    x_cgo_inittls 8
    _cgo_malloc 8
    runtime_init_done 4
    runtime_init_mu 40
    x_cgo_free 8
    _cgo_free 8
    _cgo_init 8
    _cgo_panic 48
    main 16
    x_cgo_mmap 45
    x_cgo_threadentry 8
    x_cgo_thread_start 87
    x_cgo_unsetenv 5
    _cgo_wait_runtime_init_done 77
    crosscall2 80
    threadentry 68
    x_cgo_init 143
    x_cgo_malloc 61
    x_cgo_notify_runtime_init_done 54

    [Packages]
    encoding/binary 305
    encoding/csv 5601
    flag 19081
    github 120467
    reflect 101069
    text/template 85746
    bufio 8049
    crypto/des 7241
    hash 65
    internal/singleflight 65
    math 2818
    my/crypto/rsa 2660
    os 17633
    syscall 24154
    unicode 77071
    unicode/utf8 3514
    cap 14153
    errors 224
    math/rand 13729
    sync 5649
    time 81184
    crypto 1761
    net 58352
    strings 14889
    sync/atomic 504
    $f64 392
    crypto/rand 2926
    path/filepath 10129
    runtime/cgo( 1446
    runtime/internal/atomic 448
    $f32 20
    crypto/sha256 13021
    main 10258
    runtime 1056982
    bytes 7785
    go 2176
    math/big 78009
    my/crypto/cipher 1216
    runtime/debug 832


    Another approach is to add a new column or "mark" to indicate the
    special ones, which would probably be more awk-friendly (but less
    human-eyes-friendly).
    --
    You received this message because you are subscribed to the Google Groups
    "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-dev+...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Mura at Mar 17, 2016 at 3:44 am
    FWIW, I add an attachment of the resulted patch here.
    On Wednesday, March 16, 2016 at 1:54:09 PM UTC+8, mura wrote:

    Hi,

    I have implemented two new flags (-cumsize and -pkgsize) for /cmd/nm

    The output looks like:


    $ go tool nm *-*size -sort size ./foo

    5c32e0 637567 r runtime.pclntab
    681b20 65688 D runtime.trace
    500d90 17520 T unicode.init
    67dc60 16064 D runtime.semtable
    4c55f0 13984 T time.parse
    46af40 12992 T fmt.(*pp).printReflectValue
    67ab20 12584 D runtime.mheap_
    48e4e0 10144 T crypto/sha256.block
    4c28b0 9440 T time.Time.AppendFormat
    6955e0 8192 D runtime.pdesc
    678b80 8072 D runtime.hash
    (More entries below are omitted)

    $ go tool nm* -*size *-cumsize* -sort size ./foo

    5c32e0 637567 637567 r runtime.pclntab
    681b20 65688 703255 D runtime.trace
    500d90 17520 720775 T unicode.init
    67dc60 16064 736839 D runtime.semtable
    4c55f0 13984 750823 T time.parse
    46af40 12992 763815 T fmt.(*pp).printReflectValue
    67ab20 12584 776399 D runtime.mheap_
    48e4e0 10144 786543 T crypto/sha256.block
    4c28b0 9440 795983 T time.Time.AppendFormat
    6955e0 8192 804175 D runtime.pdesc
    678b80 8072 812247 D runtime.hash
    (More entries below are omitted)

    `$ go tool nm -pkgsize ./foo` will add a table at the bottom:

    Contributions of size per package:

    runtime 1057005
    sync/atomic 504
    x_cgo_mmap 45
    x_cgo_threadentry 8
    bufio 8049
    hash 65
    runtime/debug 832
    runtime/cgo 1446
    internal/singleflight 65
    io 1793
    sync 5649
    x_cgo_inittls 8
    fatalf 206


    I wrote this for figuring out why my programs are so huge, and hopefully
    being able to replace some heavy weight dependencies with simplified ones.
    (Those programs need to be transmitted over serial ports and probably
    telephone lines so size matters.)
    The modification is pretty straightforward. If it is useful for others and
    compatible with the purpose of /cmd/nm, I will submit it for review.
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedMar 16, '16 at 5:54a
activeMar 17, '16 at 3:44a
posts9
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase