llvm.org GIT mirror llvm / 9f2f3bb
Don't return error_code from a function that doesn't fail. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241039 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
4 changed file(s) with 12 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
243243 std::error_code
244244 getRelocationTypeName(DataRefImpl Rel,
245245 SmallVectorImpl &Result) const override;
246 std::error_code getRelocationHidden(DataRefImpl Rel,
247 bool &Result) const override;
246 bool getRelocationHidden(DataRefImpl Rel) const override;
248247 uint8_t getRelocationLength(DataRefImpl Rel) const;
249248
250249 // MachO specific.
5757 /// @brief Indicates whether this relocation should hidden when listing
5858 /// relocations, usually because it is the trailing part of a multipart
5959 /// relocation that will be printed as part of the leading relocation.
60 std::error_code getHidden(bool &Result) const;
60 bool getHidden() const;
6161
6262 /// @brief Get a string that represents the type of this relocation.
6363 ///
245245 virtual std::error_code
246246 getRelocationTypeName(DataRefImpl Rel,
247247 SmallVectorImpl &Result) const = 0;
248 virtual std::error_code getRelocationHidden(DataRefImpl Rel,
249 bool &Result) const {
250 Result = false;
251 return std::error_code();
252 }
248 virtual bool getRelocationHidden(DataRefImpl Rel) const { return false; }
253249
254250 public:
255251 uint64_t getCommonSymbolSize(DataRefImpl Symb) const {
471467 return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
472468 }
473469
474 inline std::error_code RelocationRef::getHidden(bool &Result) const {
475 return OwningObject->getRelocationHidden(RelocationPimpl, Result);
470 inline bool RelocationRef::getHidden() const {
471 return OwningObject->getRelocationHidden(RelocationPimpl);
476472 }
477473
478474 inline DataRefImpl RelocationRef::getRawDataRefImpl() const {
769769 return std::error_code();
770770 }
771771
772 std::error_code MachOObjectFile::getRelocationHidden(DataRefImpl Rel,
773 bool &Result) const {
772 bool MachOObjectFile::getRelocationHidden(DataRefImpl Rel) const {
774773 unsigned Arch = getArch();
775774 uint64_t Type = getRelocationType(Rel);
776
777 Result = false;
778775
779776 // On arches that use the generic relocations, GENERIC_RELOC_PAIR
780777 // is always hidden.
781778 if (Arch == Triple::x86 || Arch == Triple::arm || Arch == Triple::ppc) {
782 if (Type == MachO::GENERIC_RELOC_PAIR) Result = true;
779 if (Type == MachO::GENERIC_RELOC_PAIR)
780 return true;
783781 } else if (Arch == Triple::x86_64) {
784782 // On x86_64, X86_64_RELOC_UNSIGNED is hidden only when it follows
785783 // an X86_64_RELOC_SUBTRACTOR.
788786 RelPrev.d.a--;
789787 uint64_t PrevType = getRelocationType(RelPrev);
790788 if (PrevType == MachO::X86_64_RELOC_SUBTRACTOR)
791 Result = true;
789 return true;
792790 }
793791 }
794792
795 return std::error_code();
793 return false;
796794 }
797795
798796 uint8_t MachOObjectFile::getRelocationLength(DataRefImpl Rel) const {
887887
888888 // Print relocation for instruction.
889889 while (rel_cur != rel_end) {
890 bool hidden = false;
890 bool hidden = rel_cur->getHidden();
891891 uint64_t addr = rel_cur->getOffset();
892892 SmallString<16> name;
893893 SmallString<32> val;
894894
895895 // If this relocation is hidden, skip it.
896 if (error(rel_cur->getHidden(hidden))) goto skip_print_rel;
897896 if (hidden) goto skip_print_rel;
898897
899898 // Stop when rel_cur's address is past the current instruction.
928927 continue;
929928 outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
930929 for (const RelocationRef &Reloc : Section.relocations()) {
931 bool hidden;
930 bool hidden = Reloc.getHidden();
932931 uint64_t address = Reloc.getOffset();
933932 SmallString<32> relocname;
934933 SmallString<32> valuestr;
935 if (error(Reloc.getHidden(hidden)))
936 continue;
937934 if (hidden)
938935 continue;
939936 if (error(Reloc.getTypeName(relocname)))