@@ -112,13 +112,18 @@ void BinaryFunction::parseLSDA(ArrayRef<uint8_t> LSDASectionData,
112112 uint64_t Offset = getLSDAAddress () - LSDASectionAddress;
113113 assert (Data.isValidOffset (Offset) && " wrong LSDA address" );
114114
115- uint8_t LPStartEncoding = Data.getU8 (&Offset);
116- uint64_t LPStart = 0 ;
117- // Convert to offset if LPStartEncoding is typed absptr DW_EH_PE_absptr
118- if (std::optional<uint64_t > MaybeLPStart = Data.getEncodedPointer (
119- &Offset, LPStartEncoding, Offset + LSDASectionAddress))
120- LPStart = (LPStartEncoding && 0xFF == 0 ) ? *MaybeLPStart
121- : *MaybeLPStart - Address;
115+ const uint8_t LPStartEncoding = Data.getU8 (&Offset);
116+ uint64_t LPStart = Address;
117+ if (LPStartEncoding != dwarf::DW_EH_PE_omit) {
118+ std::optional<uint64_t > MaybeLPStart = Data.getEncodedPointer (
119+ &Offset, LPStartEncoding, Offset + LSDASectionAddress);
120+ if (!MaybeLPStart) {
121+ errs () << " BOLT-ERROR: unsupported LPStartEncoding: "
122+ << (unsigned )LPStartEncoding << ' \n ' ;
123+ exit (1 );
124+ }
125+ LPStart = *MaybeLPStart;
126+ }
122127
123128 const uint8_t TTypeEncoding = Data.getU8 (&Offset);
124129 LSDATypeEncoding = TTypeEncoding;
@@ -175,38 +180,38 @@ void BinaryFunction::parseLSDA(ArrayRef<uint8_t> LSDASectionData,
175180 uint64_t LandingPad = *Data.getEncodedPointer (
176181 &CallSitePtr, CallSiteEncoding, CallSitePtr + LSDASectionAddress);
177182 uint64_t ActionEntry = Data.getULEB128 (&CallSitePtr);
178-
179- uint64_t LPOffset = LPStart + LandingPad;
180- uint64_t LPAddress = Address + LPOffset;
181-
182- // Verify if landing pad code is located outside current function
183- // Support landing pad to builtin_unreachable
184- if (LPAddress < Address || LPAddress > Address + getSize ()) {
185- BinaryFunction *Fragment =
186- BC.getBinaryFunctionContainingAddress (LPAddress);
187- assert (Fragment != nullptr &&
188- " BOLT-ERROR: cannot find landing pad fragment" );
189- BC.addInterproceduralReference (this , Fragment->getAddress ());
190- BC.processInterproceduralReferences ();
191- assert (isParentOrChildOf (*Fragment) &&
192- " BOLT-ERROR: cannot have landing pads in different functions" );
193- setHasIndirectTargetToSplitFragment (true );
194- BC.addFragmentsToSkip (this );
195- return ;
196- }
183+ if (LandingPad)
184+ LandingPad += LPStart;
197185
198186 if (opts::PrintExceptions) {
199187 outs () << " Call Site: [0x" << Twine::utohexstr (RangeBase + Start)
200188 << " , 0x" << Twine::utohexstr (RangeBase + Start + Length)
201- << " ); landing pad: 0x" << Twine::utohexstr (LPOffset )
189+ << " ); landing pad: 0x" << Twine::utohexstr (LandingPad )
202190 << " ; action entry: 0x" << Twine::utohexstr (ActionEntry) << " \n " ;
203191 outs () << " current offset is " << (CallSitePtr - CallSiteTableStart)
204192 << ' \n ' ;
205193 }
206194
207195 // Create a handler entry if necessary.
208196 MCSymbol *LPSymbol = nullptr ;
209- if (LPOffset) {
197+ if (LandingPad) {
198+ // Verify if landing pad code is located outside current function
199+ // Support landing pad to builtin_unreachable
200+ if (LandingPad < Address || LandingPad > Address + getSize ()) {
201+ BinaryFunction *Fragment =
202+ BC.getBinaryFunctionContainingAddress (LandingPad);
203+ assert (Fragment != nullptr &&
204+ " BOLT-ERROR: cannot find landing pad fragment" );
205+ BC.addInterproceduralReference (this , Fragment->getAddress ());
206+ BC.processInterproceduralReferences ();
207+ assert (isParentOrChildOf (*Fragment) &&
208+ " BOLT-ERROR: cannot have landing pads in different functions" );
209+ setHasIndirectTargetToSplitFragment (true );
210+ BC.addFragmentsToSkip (this );
211+ return ;
212+ }
213+
214+ const uint64_t LPOffset = LandingPad - getAddress ();
210215 if (!getInstructionAtOffset (LPOffset)) {
211216 if (opts::Verbosity >= 1 )
212217 errs () << " BOLT-WARNING: landing pad " << Twine::utohexstr (LPOffset)
0 commit comments