@@ -103,8 +103,8 @@ InputSectionBase::InputSectionBase(ObjFile<ELFT> &file,
103
103
size_t InputSectionBase::getSize () const {
104
104
if (auto *s = dyn_cast<SyntheticSection>(this ))
105
105
return s->getSize ();
106
- if (uncompressedSize >= 0 )
107
- return uncompressedSize ;
106
+ if (compressed )
107
+ return size ;
108
108
return rawData.size () - bytesDropped;
109
109
}
110
110
@@ -121,7 +121,6 @@ static void decompressAux(const InputSectionBase &sec, uint8_t *out,
121
121
}
122
122
123
123
void InputSectionBase::decompress () const {
124
- size_t size = uncompressedSize;
125
124
uint8_t *uncompressedBuf;
126
125
{
127
126
static std::mutex mu;
@@ -131,7 +130,7 @@ void InputSectionBase::decompress() const {
131
130
132
131
invokeELFT (decompressAux, *this , uncompressedBuf, size);
133
132
rawData = makeArrayRef (uncompressedBuf, size);
134
- uncompressedSize = - 1 ;
133
+ compressed = false ;
135
134
}
136
135
137
136
template <class ELFT > RelsOrRelas<ELFT> InputSectionBase::relsOrRelas () const {
@@ -230,7 +229,8 @@ template <typename ELFT> void InputSectionBase::parseCompressedHeader() {
230
229
return ;
231
230
}
232
231
233
- uncompressedSize = hdr->ch_size ;
232
+ compressed = true ;
233
+ size = hdr->ch_size ;
234
234
alignment = std::max<uint32_t >(hdr->ch_addralign , 1 );
235
235
}
236
236
@@ -1102,10 +1102,10 @@ template <class ELFT> void InputSection::writeTo(uint8_t *buf) {
1102
1102
1103
1103
// If this is a compressed section, uncompress section contents directly
1104
1104
// to the buffer.
1105
- if (uncompressedSize >= 0 ) {
1105
+ if (compressed ) {
1106
1106
auto *hdr = reinterpret_cast <const typename ELFT::Chdr *>(rawData.data ());
1107
1107
auto compressed = rawData.slice (sizeof (typename ELFT::Chdr));
1108
- size_t size = uncompressedSize ;
1108
+ size_t size = this -> size ;
1109
1109
if (Error e = hdr->ch_type == ELFCOMPRESS_ZLIB
1110
1110
? compression::zlib::decompress (compressed, buf, size)
1111
1111
: compression::zstd::decompress (compressed, buf, size))
0 commit comments