llvm-capstone/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
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
ConstantPools.cpp
ELFObjectWriter.cpp [MC][ELF] Improve st_size propagation rule 2022-04-08 10:06:44 -07:00
MachObjectWriter.cpp
MCAsmBackend.cpp
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
MCAsmInfoWasm.cpp
MCAsmInfoXCOFF.cpp
MCAsmMacro.cpp
MCAsmStreamer.cpp
MCAssembler.cpp
MCCodeEmitter.cpp
MCCodeView.cpp
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
MCExpr.cpp
MCFragment.cpp
MCInst.cpp
MCInstPrinter.cpp
MCInstrAnalysis.cpp
MCInstrDesc.cpp
MCInstrInfo.cpp
MCLabel.cpp
MCLinkerOptimizationHint.cpp
MCMachObjectTargetWriter.cpp
MCMachOStreamer.cpp
MCNullStreamer.cpp
MCObjectFileInfo.cpp Add DXContainer 2022-03-29 14:34:23 -05:00
MCObjectStreamer.cpp
MCObjectWriter.cpp
MCPseudoProbe.cpp [llvm-profgen] Decoding pseudo probe for profiled function only. 2022-03-23 14:15:11 -07:00
MCRegisterInfo.cpp
MCSchedule.cpp
MCSection.cpp
MCSectionCOFF.cpp
MCSectionELF.cpp
MCSectionMachO.cpp
MCSectionWasm.cpp
MCSectionXCOFF.cpp
MCStreamer.cpp
MCSubtargetInfo.cpp
MCSymbol.cpp
MCSymbolELF.cpp
MCSymbolXCOFF.cpp
MCTargetOptions.cpp
MCTargetOptionsCommandFlags.cpp
MCValue.cpp
MCWasmObjectTargetWriter.cpp
MCWasmStreamer.cpp
MCWin64EH.cpp Fix nulltpr typo in comment. NFC 2022-04-04 09:05:06 -07:00
MCWinCOFFStreamer.cpp
MCWinEH.cpp
MCXCOFFObjectTargetWriter.cpp
MCXCOFFStreamer.cpp
StringTableBuilder.cpp
SubtargetFeature.cpp
TargetRegistry.cpp
WasmObjectWriter.cpp
WinCOFFObjectWriter.cpp
XCOFFObjectWriter.cpp