+/* This file is part of centaur.
+ *
+ * centaur is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License 2 as
+ * published by the Free Software Foundation.
+
+ * centaur is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with centaur. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include <assert.h>
#include <stdlib.h>
#include <string.h>
ElfuPhdr *mp;
ElfuScn *ms;
- // TODO: Sort PHDRs by offset before interating
-
CIRCLEQ_FOREACH(mp, &me->phdrList, elem) {
if (mp->phdr.p_type != PT_LOAD) {
continue;
{
assert(ms);
- // TODO: Free symtab/reltab
+ if (!CIRCLEQ_EMPTY(&ms->symtab.syms)) {
+ ElfuSym *nextsym;
+
+ nextsym = CIRCLEQ_FIRST(&ms->symtab.syms);
+ while ((void*)nextsym != (void*)&ms->symtab.syms) {
+ ElfuSym *cursym = nextsym;
+ nextsym = CIRCLEQ_NEXT(cursym, elem);
+ CIRCLEQ_REMOVE(&ms->symtab.syms, cursym, elem);
+ free(cursym);
+ }
+ }
+
+ if (!CIRCLEQ_EMPTY(&ms->reltab.rels)) {
+ ElfuRel *nextrel;
+
+ nextrel = CIRCLEQ_FIRST(&ms->reltab.rels);
+ while ((void*)nextrel != (void*)&ms->reltab.rels) {
+ ElfuRel *currel = nextrel;
+ nextrel = CIRCLEQ_NEXT(currel, elem);
+ CIRCLEQ_REMOVE(&ms->reltab.rels, currel, elem);
+ free(currel);
+ }
+ }
if (ms->databuf) {
free(ms->databuf);