@@ -1990,8 +1990,7 @@ void ObjCMethListSection::setUp() {
1990
1990
for (const ConcatInputSection *isec : inputs) {
1991
1991
uint32_t structSizeAndFlags = 0 , structCount = 0 ;
1992
1992
readMethodListHeader (isec->data .data (), structSizeAndFlags, structCount);
1993
- uint32_t structSize = structSizeAndFlags & m_structSizeMask;
1994
-
1993
+ uint32_t originalStructSize = structSizeAndFlags & structSizeMask;
1995
1994
// Method name is immediately after header
1996
1995
uint32_t methodNameOff = methodListHeaderSize;
1997
1996
@@ -2008,7 +2007,7 @@ void ObjCMethListSection::setUp() {
2008
2007
ObjCSelRefsHelper::makeSelRef (methname);
2009
2008
2010
2009
// Jump to method name offset in next struct
2011
- methodNameOff += structSize ;
2010
+ methodNameOff += originalStructSize ;
2012
2011
}
2013
2012
}
2014
2013
}
@@ -2137,8 +2136,15 @@ ObjCMethListSection::writeRelativeMethodList(const ConcatInputSection *isec,
2137
2136
// value flag
2138
2137
uint32_t structSizeAndFlags = 0 , structCount = 0 ;
2139
2138
readMethodListHeader (isec->data .data (), structSizeAndFlags, structCount);
2140
- structSizeAndFlags |= relMethodHeaderFlag;
2141
- writeMethodListHeader (buf, structSizeAndFlags, structCount);
2139
+ // Set the struct size for the relative method list
2140
+ uint32_t relativeStructSizeAndFlags =
2141
+ (relativeOffsetSize * pointersPerStruct) & structSizeMask;
2142
+ // Carry over the old flags from the input struct
2143
+ relativeStructSizeAndFlags |= structSizeAndFlags & structFlagsMask;
2144
+ // Set the relative method list flag
2145
+ relativeStructSizeAndFlags |= relMethodHeaderFlag;
2146
+
2147
+ writeMethodListHeader (buf, relativeStructSizeAndFlags, structCount);
2142
2148
2143
2149
assert (methodListHeaderSize +
2144
2150
(structCount * pointersPerStruct * target->wordSize ) ==
0 commit comments