@@ -161,18 +161,23 @@ static bool objc_build_refs(RCoreObjc *objc) {
161161 const size_t word_size = objc -> word_size ; // assuming 8 because of the read_le64
162162 if (!r_io_read_at (objc -> core -> io , objc -> _const -> vaddr , buf , ss_const )) {
163163 R_LOG_WARN ("aao: Cannot read the whole const section %u" , (unsigned int )ss_const );
164- return false ;
164+ goto beach ;
165165 }
166- for (off = 0 ; off + word_size < ss_const && off + word_size < maxsize ; off += word_size ) {
166+ for (off = 0 ; off + word_size <= ss_const && off + word_size < maxsize ; off += word_size ) {
167167 ut64 va = va_const + off ;
168168 ut64 xrefs_to = (word_size == 8 )? r_read_le64 (buf + off ): r_read_le32 (buf + off );
169169 if (isValid (xrefs_to )) {
170+ #if 1
170171 array_add (objc , va , xrefs_to );
172+ #else
173+ // array_add (objc, xrefs_to, va);
174+ #endif
175+
171176 }
172177 }
173178 if (!r_io_read_at (objc -> core -> io , va_selrefs , buf , ss_selrefs )) {
174179 R_LOG_WARN ("aao: Cannot read the whole selrefs section" );
175- return false ;
180+ goto beach ;
176181 }
177182 for (off = 0 ; off + word_size < ss_selrefs && off + word_size < maxsize ; off += word_size ) {
178183 ut64 va = va_selrefs + off ;
@@ -181,6 +186,22 @@ static bool objc_build_refs(RCoreObjc *objc) {
181186 array_add (objc , xrefs_to , va );
182187 }
183188 }
189+ if (objc -> _msgrefs ) {
190+ const ut64 va_msgrefs = objc -> _msgrefs -> vaddr ;
191+ size_t ss_msgrefs = R_MIN (objc -> _msgrefs -> vsize , maxsize );
192+ if (!r_io_read_at (objc -> core -> io , va_msgrefs , buf , ss_msgrefs )) {
193+ R_LOG_WARN ("aao: Cannot read the whole msgrefs section" );
194+ goto beach ;
195+ }
196+ for (off = 0 ; off + word_size <= ss_msgrefs && off + word_size <= maxsize ; off += (word_size * 2 )) {
197+ ut64 va = va_msgrefs + off ;
198+ ut64 xrefs_to = (word_size == 8 )? r_read_le64 (buf + off ): r_read_le32 (buf + off );
199+ if (isValid (xrefs_to )) {
200+ array_add (objc , xrefs_to , va );
201+ }
202+ }
203+ }
204+ beach :
184205 free (buf );
185206 return true;
186207}
0 commit comments