facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.21k stars 3k forks source link

fix .stapsdt.base section in folly_sdt macro #9517

Closed sonntex closed 1 month ago

sonntex commented 1 month ago

Summary: X-link: https://github.com/facebook/folly/pull/2307

Fix .stapsdt.base section in FOLLY_SDT macro.

Ported .stapsdt.base initialization from sys/sdt.h https://github.com/jav/systemtap/blob/2da355dd02a18bf4f67e2ceeb504b351b4bd5b83/includes/sys/sdt.h#L174C1-L199C21.

#define _SDT_ASM_BODY(provider, name, pack_args, args)                \
  _SDT_ASM_1(990:   _SDT_NOP)                         \
  _SDT_ASM_3(       .pushsection .note.stapsdt,_SDT_ASM_AUTOGROUP,"note") \
  _SDT_ASM_1(       .balign 4)                        \
  _SDT_ASM_3(       .4byte 992f-991f, 994f-993f, _SDT_NOTE_TYPE)          \
  _SDT_ASM_1(991:   .asciz _SDT_NOTE_NAME)                    \
  _SDT_ASM_1(992:   .balign 4)                        \
  _SDT_ASM_1(993:   _SDT_ASM_ADDR 990b)                   \
  _SDT_ASM_1(       _SDT_ASM_ADDR _.stapsdt.base)                 \
  _SDT_SEMAPHORE(provider,name)                           \
  _SDT_ASM_STRING(provider)                           \
  _SDT_ASM_STRING(name)                               \
  pack_args args                                  \
  _SDT_ASM_1(994:   .balign 4)                        \
  _SDT_ASM_1(       .popsection)

#define _SDT_ASM_BASE                                 \
  _SDT_ASM_1(.ifndef _.stapsdt.base)                          \
  _SDT_ASM_5(       .pushsection .stapsdt.base,"aG","progbits",       \
                            .stapsdt.base,comdat) \
  _SDT_ASM_1(       .weak _.stapsdt.base)                     \
  _SDT_ASM_1(       .hidden _.stapsdt.base)                   \
  _SDT_ASM_1(   _.stapsdt.base: .space 1)                     \
  _SDT_ASM_2(       .size _.stapsdt.base, 1)                  \
  _SDT_ASM_1(       .popsection)                          \
  _SDT_ASM_1(.endif)

This section might be discarded explicitly using --discard-section=.stapsdt.base https://fburl.com/code/0pbird2s or implicitly using --gc-sections https://fburl.com/code/iy16v9v8. Use linker script to keep it if your build system sets --gc-sections implicitly.

Reviewed By: nslingerland

Differential Revision: D61148295

facebook-github-bot commented 1 month ago

This pull request was exported from Phabricator. Differential Revision: D61148295

facebook-github-bot commented 1 month ago

This pull request was exported from Phabricator. Differential Revision: D61148295

facebook-github-bot commented 1 month ago

This pull request was exported from Phabricator. Differential Revision: D61148295

facebook-github-bot commented 1 month ago

This pull request has been merged in facebook/hhvm@003593b43465f243be08f3c08dab2ac6da7e5fec.