llvm.org GIT mirror llvm / 481f35f
Simplify another function that doesn't fail. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238703 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
14 changed file(s) with 31 addition(s) and 48 deletion(s). Raw diff Collapse all Expand all
612612 StringRef &Res) const override;
613613 std::error_code getSymbolAddress(DataRefImpl Symb,
614614 uint64_t &Res) const override;
615 std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
615 uint64_t getSymbolSize(DataRefImpl Symb) const override;
616616 uint32_t getSymbolFlags(DataRefImpl Symb) const override;
617617 std::error_code getSymbolType(DataRefImpl Symb,
618618 SymbolRef::Type &Res) const override;
7979 std::error_code getSymbolAddress(DataRefImpl Symb,
8080 uint64_t &Res) const override;
8181 uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
82 std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
82 uint64_t getSymbolSize(DataRefImpl Symb) const override;
8383 uint32_t getSymbolFlags(DataRefImpl Symb) const override;
8484 std::error_code getSymbolOther(DataRefImpl Symb, uint8_t &Res) const override;
8585 std::error_code getSymbolType(DataRefImpl Symb,
332332 }
333333
334334 template
335 std::error_code ELFObjectFile::getSymbolSize(DataRefImpl Symb,
336 uint64_t &Result) const {
337 Result = toELFSymIter(Symb)->st_size;
338 return object_error::success;
335 uint64_t ELFObjectFile::getSymbolSize(DataRefImpl Symb) const {
336 return toELFSymIter(Symb)->st_size;
339337 }
340338
341339 template
204204 std::error_code getSymbolAddress(DataRefImpl Symb,
205205 uint64_t &Res) const override;
206206 uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
207 std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
207 uint64_t getSymbolSize(DataRefImpl Symb) const override;
208208 std::error_code getSymbolType(DataRefImpl Symb,
209209 SymbolRef::Type &Res) const override;
210210 uint32_t getSymbolFlags(DataRefImpl Symb) const override;
146146 std::error_code getAddress(uint64_t &Result) const;
147147 /// @brief Get the alignment of this symbol as the actual value (not log 2).
148148 uint32_t getAlignment() const;
149 std::error_code getSize(uint64_t &Result) const;
149 uint64_t getSize() const;
150150 std::error_code getType(SymbolRef::Type &Result) const;
151151 std::error_code getOther(uint8_t &Result) const;
152152
206206 virtual std::error_code getSymbolAddress(DataRefImpl Symb,
207207 uint64_t &Res) const = 0;
208208 virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
209 virtual std::error_code getSymbolSize(DataRefImpl Symb,
210 uint64_t &Res) const = 0;
209 virtual uint64_t getSymbolSize(DataRefImpl Symb) const = 0;
211210 virtual std::error_code getSymbolType(DataRefImpl Symb,
212211 SymbolRef::Type &Res) const = 0;
213212 virtual std::error_code getSymbolSection(DataRefImpl Symb,
336335 return getObject()->getSymbolAlignment(getRawDataRefImpl());
337336 }
338337
339 inline std::error_code SymbolRef::getSize(uint64_t &Result) const {
340 return getObject()->getSymbolSize(getRawDataRefImpl(), Result);
338 inline uint64_t SymbolRef::getSize() const {
339 return getObject()->getSymbolSize(getRawDataRefImpl());
341340 }
342341
343342 inline std::error_code SymbolRef::getSection(section_iterator &Result) const {
386386 uint32_t Flags = I->getFlags();
387387 if (Flags & SymbolRef::SF_Common) {
388388 // Add the common symbols to a list. We'll allocate them all below.
389 uint64_t Size = 0;
390 Check(I->getSize(Size));
389 uint64_t Size = I->getSize();
391390 CommonSize += Size;
392391 }
393392 }
494493 }
495494
496495 uint32_t Align = Sym.getAlignment();
497 uint64_t Size = 0;
498 Check(Sym.getSize(Size));
496 uint64_t Size = Sym.getSize();
499497
500498 CommonSize += Align + Size;
501499 SymbolsToAllocate.push_back(Sym);
517515 // Assign the address of each symbol
518516 for (auto &Sym : SymbolsToAllocate) {
519517 uint32_t Align = Sym.getAlignment();
520 uint64_t Size;
521518 StringRef Name;
522 Check(Sym.getSize(Size));
519 uint64_t Size = Sym.getSize();
523520 Check(Sym.getName(Name));
524521 if (Align) {
525522 // This symbol has an alignment requirement.
235235 return Result;
236236 }
237237
238 std::error_code COFFObjectFile::getSymbolSize(DataRefImpl Ref,
239 uint64_t &Result) const {
238 uint64_t COFFObjectFile::getSymbolSize(DataRefImpl Ref) const {
240239 COFFSymbolRef Symb = getCOFFSymbol(Ref);
241240
242241 if (Symb.isCommon())
243 Result = Symb.getValue();
244 else
245 Result = UnknownAddressOrSize;
246
247 return object_error::success;
242 return Symb.getValue();
243 return UnknownAddressOrSize;
248244 }
249245
250246 std::error_code
409409 return 0;
410410 }
411411
412 std::error_code MachOObjectFile::getSymbolSize(DataRefImpl DRI,
413 uint64_t &Result) const {
412 uint64_t MachOObjectFile::getSymbolSize(DataRefImpl DRI) const {
414413 uint64_t Value;
415414 getSymbolAddress(DRI, Value);
416415 uint32_t flags = getSymbolFlags(DRI);
417416 if (flags & SymbolRef::SF_Common)
418 Result = Value;
419 else
420 Result = UnknownAddressOrSize;
421 return object_error::success;
417 return Value;
418 return UnknownAddressOrSize;
422419 }
423420
424421 std::error_code MachOObjectFile::getSymbolType(DataRefImpl Symb,
186186 }
187187
188188 uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI) {
189 uint64_t ret;
190 if (std::error_code ec = (*unwrap(SI))->getSize(ret))
191 report_fatal_error(ec.message());
192 return ret;
189 return (*unwrap(SI))->getSize();
193190 }
194191
195192 // RelocationRef accessors
3030
3131 StringRef SymName; SymI->getName(SymName);
3232 uint64_t SymAddr; SymI->getAddress(SymAddr);
33 uint64_t SymSize; SymI->getSize(SymSize);
33 uint64_t SymSize = SymI->getSize();
3434 int64_t Addend; getELFRelocationAddend(Rel, Addend);
3535
3636 MCSymbol *Sym = Ctx.getOrCreateSymbol(SymName);
203203 StringRef SecContents;
204204 if (error(Sec.getContents(SecContents)))
205205 return;
206 uint64_t SymAddress, SymSize;
207 if (error(Sym.getAddress(SymAddress)) || error(Sym.getSize(SymSize)))
206 uint64_t SymAddress;
207 if (error(Sym.getAddress(SymAddress)))
208208 return;
209 uint64_t SymSize = Sym.getSize();
209210 uint64_t SecAddress = Sec.getAddress();
210211 uint64_t SecSize = Sec.getSize();
211212 uint64_t SymOffset = SymAddress - SecAddress;
933933 S.Address = UnknownAddressOrSize;
934934 if (PrintSize && isa(Obj)) {
935935 symbol_iterator SymI = I;
936 if (error(SymI->getSize(S.Size)))
937 break;
936 S.Size = SymI->getSize();
938937 }
939938 if (PrintAddress && isa(Obj))
940939 if (error(symbol_iterator(I)->getAddress(S.Address)))
675675 StringRef Name;
676676 uint64_t Address;
677677 SymbolRef::Type Type;
678 uint64_t Size;
679678 uint32_t Flags = Symbol.getFlags();
680679 section_iterator Section = o->section_end();
681680 if (error(Symbol.getName(Name)))
684683 continue;
685684 if (error(Symbol.getType(Type)))
686685 continue;
687 if (error(Symbol.getSize(Size)))
688 continue;
686 uint64_t Size = Symbol.getSize();
689687 if (error(Symbol.getSection(Section)))
690688 continue;
691689
291291
292292 uint64_t Size;
293293 if (isa(SymbolObj)) {
294 if (Sym.getSize(Size))
295 continue;
294 Size = Sym.getSize();
296295 } else {
297296 object::section_iterator Sec = SymbolObj->section_end();
298297 if (Sym.getSection(Sec))
112112 // occupies the memory range up to the following symbol.
113113 if (isa(Module))
114114 SymbolSize = 0;
115 else if (error(Symbol.getSize(SymbolSize)) ||
116 SymbolSize == UnknownAddressOrSize)
117 return;
115 else {
116 SymbolSize = Symbol.getSize();
117 if (SymbolSize == UnknownAddressOrSize)
118 return;
119 }
118120 StringRef SymbolName;
119121 if (error(Symbol.getName(SymbolName)))
120122 return;