@@ -71,8 +71,10 @@ InputSectionBase::InputSectionBase(InputFile *file, StringRef name,
7171 // The ELF spec states that a value of 0 means the section has
7272 // no alignment constraints.
7373 uint32_t v = std::max<uint32_t >(addralign, 1 );
74- if (!isPowerOf2_64 (v))
75- Fatal (getCtx ()) << this << " : sh_addralign is not a power of 2" ;
74+ if (!isPowerOf2_64 (v)) {
75+ Err (getCtx ()) << this << " : sh_addralign is not a power of 2" ;
76+ v = 1 ;
77+ }
7678 this ->addralign = v;
7779
7880 // If SHF_COMPRESSED is set, parse the header. The legacy .zdebug format is no
@@ -104,8 +106,10 @@ InputSectionBase::InputSectionBase(ObjFile<ELFT> &file,
104106 // We reject object files having insanely large alignments even though
105107 // they are allowed by the spec. I think 4GB is a reasonable limitation.
106108 // We might want to relax this in the future.
107- if (hdr.sh_addralign > UINT32_MAX)
108- Fatal (getCtx ()) << &file << " : section sh_addralign is too large" ;
109+ if (hdr.sh_addralign > UINT32_MAX) {
110+ Err (getCtx ()) << &file << " : section sh_addralign is too large" ;
111+ addralign = 1 ;
112+ }
109113}
110114
111115size_t InputSectionBase::getSize () const {
@@ -123,7 +127,7 @@ static void decompressAux(Ctx &ctx, const InputSectionBase &sec, uint8_t *out,
123127 if (Error e = hdr->ch_type == ELFCOMPRESS_ZLIB
124128 ? compression::zlib::decompress (compressed, out, size)
125129 : compression::zstd::decompress (compressed, out, size))
126- Fatal (ctx) << &sec << " : decompress failed: " << std::move (e);
130+ Err (ctx) << &sec << " : decompress failed: " << std::move (e);
127131}
128132
129133void InputSectionBase::decompress () const {
@@ -649,9 +653,11 @@ static uint64_t getRISCVUndefinedRelativeWeakVA(uint64_t type, uint64_t p) {
649653// of the RW segment.
650654static uint64_t getARMStaticBase (const Symbol &sym) {
651655 OutputSection *os = sym.getOutputSection ();
652- if (!os || !os->ptLoad || !os->ptLoad ->firstSec )
653- Fatal (os->ctx ) << " SBREL relocation to " << sym.getName ()
654- << " without static base" ;
656+ if (!os || !os->ptLoad || !os->ptLoad ->firstSec ) {
657+ Err (os->ctx ) << " SBREL relocation to " << sym.getName ()
658+ << " without static base" ;
659+ return 0 ;
660+ }
655661 return os->ptLoad ->firstSec ->addr ;
656662}
657663
@@ -1304,7 +1310,7 @@ template <class ELFT> void InputSection::writeTo(Ctx &ctx, uint8_t *buf) {
13041310 if (Error e = hdr->ch_type == ELFCOMPRESS_ZLIB
13051311 ? compression::zlib::decompress (compressed, buf, size)
13061312 : compression::zstd::decompress (compressed, buf, size))
1307- Fatal (ctx) << this << " : decompress failed: " << std::move (e);
1313+ Err (ctx) << this << " : decompress failed: " << std::move (e);
13081314 uint8_t *bufEnd = buf + size;
13091315 relocate<ELFT>(ctx, buf, bufEnd);
13101316 return ;
0 commit comments