$OpenBSD: patch-src_cmd_8l_asm_c,v 1.1 2012/09/19 21:10:38 sthen Exp $ --- src/cmd/8l/asm.c.orig Thu Jun 14 04:23:38 2012 +++ src/cmd/8l/asm.c Mon Sep 17 11:38:32 2012 @@ -91,6 +91,7 @@ enum { ElfStrGnuVersion, ElfStrGnuVersionR, ElfStrNoteNetbsdIdent, + ElfStrNoteOpenbsdIdent, ElfStrNoPtrData, ElfStrNoPtrBss, NElfStr @@ -534,6 +535,8 @@ doelf(void) elfstr[ElfStrNoPtrBss] = addstring(shstrtab, ".noptrbss"); if(HEADTYPE == Hnetbsd) elfstr[ElfStrNoteNetbsdIdent] = addstring(shstrtab, ".note.netbsd.ident"); + if(HEADTYPE == Hopenbsd) + elfstr[ElfStrNoteOpenbsdIdent] = addstring(shstrtab, ".note.openbsd.ident"); addstring(shstrtab, ".elfdata"); addstring(shstrtab, ".rodata"); addstring(shstrtab, ".gosymtab"); @@ -721,7 +724,7 @@ asmb(void) if(elfverneed) elftextsh += 2; } - if(HEADTYPE == Hnetbsd) + if(HEADTYPE == Hnetbsd || HEADTYPE == Hopenbsd) elftextsh += 1; } @@ -995,12 +998,18 @@ asmb(void) phsh(ph, sh); } - if(HEADTYPE == Hnetbsd) { - sh = newElfShdr(elfstr[ElfStrNoteNetbsdIdent]); - sh->type = SHT_NOTE; - sh->flags = SHF_ALLOC; - sh->addralign = 4; - resoff -= elfnetbsdsig(sh, startva, resoff); + if(HEADTYPE == Hnetbsd || HEADTYPE == Hopenbsd) { + sh = nil; + switch (HEADTYPE) { + case Hnetbsd: + sh = newElfShdr(elfstr[ElfStrNoteNetbsdIdent]); + resoff -= elfnetbsdsig(sh, startva, resoff); + break; + case Hopenbsd: + sh = newElfShdr(elfstr[ElfStrNoteOpenbsdIdent]); + resoff -= elfopenbsdsig(sh, startva, resoff); + break; + } ph = newElfPhdr(); ph->type = PT_NOTE; @@ -1195,6 +1204,8 @@ asmb(void) a += elfwriteinterp(elfstr[ElfStrInterp]); if(HEADTYPE == Hnetbsd) a += elfwritenetbsdsig(elfstr[ElfStrNoteNetbsdIdent]); + if(HEADTYPE == Hopenbsd) + a += elfwriteopenbsdsig(elfstr[ElfStrNoteOpenbsdIdent]); if(a > ELFRESERVE) diag("ELFRESERVE too small: %d > %d", a, ELFRESERVE); break;