[PATCH] D96838: CodeGen: Set !retain metadata on UsedAttr definitions for Linux/FreeBSD

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 16 22:36:03 PST 2021


MaskRay created this revision.
Herald added subscribers: krytarowski, arichardson, emaste.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

GCC 11 will set SHF_GNU_RETAIN on the section of a `__attribute__((used))`
function/variable, if the configure-time GNU as supports SHF_GNU_RETAIN
(binutils 2.36 or above on Linux or FreeBSD).

This patch sets !retain metadata on UsedAttr definitions.
We let the backend to figure out whether the ELF section flag SHF_GNU_RETAIN
should be used (integrated assembler or `-fno-integrated-as -fbinutils-version=2.36`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96838

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/attr-used.c
  clang/test/CodeGenCXX/attr-used.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96838.324188.patch
Type: text/x-patch
Size: 5000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210217/dd4f710c/attachment.bin>


More information about the cfe-commits mailing list