[PATCH] D53782: [llvm-objcopy] Don't apply --localize flags to common symbols

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 29 15:01:23 PDT 2018


MaskRay added inline comments.


================
Comment at: test/tools/llvm-objcopy/localize.test:44
+    - Name:     GlobalCommon
+      Type:     STT_OBJECT
+      Index:    SHN_COMMON
----------------
jakehehrlich wrote:
> Slight oddity that doesn't really matter. If Index is SHN_COMMON then the Type should always by STT_COMMON. In relocatable files if the type STT_COMMON then the index must be SHN_COMMON. In fully linked executables it needs to be something specific but the type should still be STT_COMMON. You should never see a symbol with index SHN_COMMON without STT_COMMON. 
It does not need to be `STT_COMMON`. `Index: SHN_COMMON` suffices.

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b8871f357fdfa9c0c06d2d3e5600391d8c994f37 added some STT_COMMON support in binutils but the intention is not clear to me.

By default `.common sym, size, align` emits `STT_BOJECT`, `--elf-stt-common=` can toggle the behavior:

% as a.s --elf-stt-common=no && readelf -s a.out | grep COM   
     4: 0000000000000004     4 OBJECT  GLOBAL DEFAULT  COM sym
% as a.s --elf-stt-common=yes && readelf -s a.out | grep COMMON
     4: 0000000000000004     4 COMMON  GLOBAL DEFAULT  COM sym






Repository:
  rL LLVM

https://reviews.llvm.org/D53782





More information about the llvm-commits mailing list