llvm-project/llvm/lib/MC
Fangrui Song e07dfa5328 [MC][ELF] Improve st_size propagation rule
`.symver foo, foo@ver` creates the MCSymbolELF `foo@ver` whose almost all
attributes (including st_size) should inherit from `foo` (GNU as behavior).

a041ef1bd8 added st_size propagation which works
for many cases but fails for the following one:

```
.set __GLIBC_2_12_sys_errlist, _sys_errlist_internal
.type   __GLIBC_2_12_sys_errlist,@object
.size   __GLIBC_2_12_sys_errlist, 1080
.symver __GLIBC_2_12_sys_errlist, sys_errlist@GLIBC_2.12
...
_sys_errlist_internal:
.size   _sys_errlist_internal, 1072
```

`sys_errlist@GLIBC_2.12`'s st_size is 1072 (incorrect), which does not match
`__GLIBC_2_12_sys_errlist`'s st_size: 1080.

The problem is that `Base` is (the final) `_sys_errlist_internal` while we want
to respect (the intermediate) `__GLIBC_2_12_sys_errlist`'s st_size.
Fix this by following the MCSymbolRefExpr assignment chain and finding
the closest non-null `getSize()`, which covers most needs. Notably MCBinaryExpr
is not handled, but it is rare enough to matter.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D123283
2022-04-08 10:06:44 -07:00
..
MCDisassembler Cleanup includes: MCDisassembler 2022-03-10 14:43:29 +01:00
MCParser [Support/Hash functions] Change the `final()` and `result()` of the hashing functions to return an array of bytes 2022-04-05 21:38:06 -07:00
CMakeLists.txt Move TargetRegistry.(h|cpp) from Support to MC 2021-10-08 14:51:48 -07:00
ConstantPools.cpp [MC] Add MCSubtargetInfo to MCAlignFragment 2021-09-07 15:46:19 +01:00
ELFObjectWriter.cpp [MC][ELF] Improve st_size propagation rule 2022-04-08 10:06:44 -07:00
MCAsmBackend.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCAsmInfo.cpp [MC] Make MCAsmInfo::isAcceptableChar reflect MCAsmInfo::doesAllowAtInName 2022-03-29 14:01:32 -07:00
MCAsmInfoCOFF.cpp
MCAsmInfoDarwin.cpp
MCAsmInfoELF.cpp
MCAsmInfoGOFF.cpp [SystemZ][z/OS] Introduce the GOFFMCAsmInfo Interface for z/OS 2021-09-24 16:25:41 -04:00
MCAsmInfoWasm.cpp
MCAsmInfoXCOFF.cpp
MCAsmMacro.cpp
MCAsmStreamer.cpp [MC] Fix letter case of some MCSection member functions 2022-03-11 20:07:00 -08:00
MCAssembler.cpp [MC] Fix letter case of some MCSection member functions 2022-03-11 20:07:00 -08:00
MCCodeEmitter.cpp
MCCodeView.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCContext.cpp Add DXContainer 2022-03-29 14:34:23 -05:00
MCDwarf.cpp [Support/Hash functions] Change the `final()` and `result()` of the hashing functions to return an array of bytes 2022-04-05 21:38:06 -07:00
MCELFObjectTargetWriter.cpp
MCELFStreamer.cpp [LLVM][NFC]Inclusive language: remove occurances of sanity check/test from llvm 2021-11-24 17:29:55 -05:00
MCExpr.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCFragment.cpp [MC] Recursively calculate symbol offset 2021-10-20 14:29:43 -04:00
MCInst.cpp
MCInstPrinter.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCInstrAnalysis.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCInstrDesc.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCInstrInfo.cpp
MCLabel.cpp
MCLinkerOptimizationHint.cpp
MCMachOStreamer.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCMachObjectTargetWriter.cpp
MCNullStreamer.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCObjectFileInfo.cpp Add DXContainer 2022-03-29 14:34:23 -05:00
MCObjectStreamer.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCObjectWriter.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCPseudoProbe.cpp [llvm-profgen] Decoding pseudo probe for profiled function only. 2022-03-23 14:15:11 -07:00
MCRegisterInfo.cpp [MC] Define and use MCRegisterInfo::regsOverlap 2022-02-14 20:46:02 +00:00
MCSchedule.cpp
MCSection.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCSectionCOFF.cpp [MC] Fix letter case of some MCSection member functions 2022-03-11 20:07:00 -08:00
MCSectionELF.cpp [MC] Fix letter case of some MCSection member functions 2022-03-11 20:07:00 -08:00
MCSectionMachO.cpp [MC] Fix letter case of some MCSection member functions 2022-03-11 20:07:00 -08:00
MCSectionWasm.cpp [MC] Fix letter case of some MCSection member functions 2022-03-11 20:07:00 -08:00
MCSectionXCOFF.cpp Cleanup includes: DebugInfo & CodeGen 2022-03-12 17:26:40 +01:00
MCStreamer.cpp [MC] Fix letter case of some MCSection member functions 2022-03-11 20:07:00 -08:00
MCSubtargetInfo.cpp
MCSymbol.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCSymbolELF.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCSymbolXCOFF.cpp
MCTargetOptions.cpp
MCTargetOptionsCommandFlags.cpp
MCValue.cpp
MCWasmObjectTargetWriter.cpp
MCWasmStreamer.cpp Cleanup includes: DebugInfo & CodeGen 2022-03-12 17:26:40 +01:00
MCWin64EH.cpp Fix nulltpr typo in comment. NFC 2022-04-04 09:05:06 -07:00
MCWinCOFFStreamer.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCWinEH.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MCXCOFFObjectTargetWriter.cpp
MCXCOFFStreamer.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
MachObjectWriter.cpp MC: Use SmallVector::clear() instead of set_size(0) 2022-01-13 10:34:14 -08:00
StringTableBuilder.cpp
SubtargetFeature.cpp Cleanup LLVMMC headers 2022-02-09 11:09:17 +01:00
TargetRegistry.cpp [llvm] Use range-based for loops (NFC) 2021-12-09 09:37:29 -08:00
WasmObjectWriter.cpp [WebAssembly] Second phase of implemented extended const proposal 2022-03-14 08:55:47 -07:00
WinCOFFObjectWriter.cpp [COFF] Move section name encoding into BinaryFormat 2022-02-21 13:50:56 +02:00
XCOFFObjectWriter.cpp [XCOFF] support XCOFFObjectWriter for fileHeader and sectionHeaders in 64-bit XCOFF. 2022-03-20 09:31:29 -04:00