@@ -64,6 +64,7 @@ class ELFObjectFileBase : public ObjectFile {
64
64
virtual uint64_t getSectionOffset (DataRefImpl Sec) const = 0;
65
65
66
66
virtual Expected<int64_t > getRelocationAddend (DataRefImpl Rel) const = 0;
67
+ virtual Error getBuildAttributes (ARMAttributeParser &Attributes) const = 0;
67
68
68
69
public:
69
70
using elf_symbol_iterator_range = iterator_range<elf_symbol_iterator>;
@@ -352,6 +353,28 @@ template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
352
353
(Visibility == ELF::STV_DEFAULT || Visibility == ELF::STV_PROTECTED));
353
354
}
354
355
356
+ Error getBuildAttributes (ARMAttributeParser &Attributes) const override {
357
+ auto SectionsOrErr = EF.sections ();
358
+ if (!SectionsOrErr)
359
+ return SectionsOrErr.takeError ();
360
+
361
+ for (const Elf_Shdr &Sec : *SectionsOrErr) {
362
+ if (Sec.sh_type == ELF::SHT_ARM_ATTRIBUTES) {
363
+ auto ErrorOrContents = EF.getSectionContents (&Sec);
364
+ if (!ErrorOrContents)
365
+ return ErrorOrContents.takeError ();
366
+
367
+ auto Contents = ErrorOrContents.get ();
368
+ if (Contents[0 ] != ARMBuildAttrs::Format_Version || Contents.size () == 1 )
369
+ return Error::success ();
370
+
371
+ Attributes.Parse (Contents, ELFT::TargetEndianness == support::little);
372
+ break ;
373
+ }
374
+ }
375
+ return Error::success ();
376
+ }
377
+
355
378
// This flag is used for classof, to distinguish ELFObjectFile from
356
379
// its subclass. If more subclasses will be created, this flag will
357
380
// have to become an enum.
@@ -393,28 +416,6 @@ template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
393
416
394
417
unsigned getPlatformFlags () const override { return EF.getHeader ()->e_flags ; }
395
418
396
- std::error_code getBuildAttributes (ARMAttributeParser &Attributes) const override {
397
- auto SectionsOrErr = EF.sections ();
398
- if (!SectionsOrErr)
399
- return errorToErrorCode (SectionsOrErr.takeError ());
400
-
401
- for (const Elf_Shdr &Sec : *SectionsOrErr) {
402
- if (Sec.sh_type == ELF::SHT_ARM_ATTRIBUTES) {
403
- auto ErrorOrContents = EF.getSectionContents (&Sec);
404
- if (!ErrorOrContents)
405
- return errorToErrorCode (ErrorOrContents.takeError ());
406
-
407
- auto Contents = ErrorOrContents.get ();
408
- if (Contents[0 ] != ARMBuildAttrs::Format_Version || Contents.size () == 1 )
409
- return std::error_code ();
410
-
411
- Attributes.Parse (Contents, ELFT::TargetEndianness == support::little);
412
- break ;
413
- }
414
- }
415
- return std::error_code ();
416
- }
417
-
418
419
const ELFFile<ELFT> *getELFFile () const { return &EF; }
419
420
420
421
bool isDyldType () const { return isDyldELFObject; }
0 commit comments