Print this page
ld should reject kernel modules as input

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/libelf/common/gelf.c
          +++ new/usr/src/cmd/sgs/libelf/common/gelf.c
↓ open down ↓ 690 lines elided ↑ open up ↑
 691  691                  ((Elf64_Dyn *)dst->d_buf)[ndx] = *(Elf64_Dyn*)src;
 692  692  
 693  693          ELFUNLOCK(EDATA_ELF(dst));
 694  694          return (rc);
 695  695  }
 696  696  
 697  697  
 698  698  
 699  699  GElf_Sym *
 700  700  gelf_getsymshndx(Elf_Data *symdata, Elf_Data *shndxdata,
 701      -        int ndx, GElf_Sym *symptr, Elf32_Word *xshndx)
      701 +    int ndx, GElf_Sym *symptr, Elf32_Word *xshndx)
 702  702  {
 703  703          if (gelf_getsym(symdata, ndx, symptr) == 0)
 704  704                  return (NULL);
 705  705          if (shndxdata && xshndx) {
 706  706                  EDATA_READLOCKS(shndxdata);
 707  707                  if ((ndx * sizeof (Elf32_Word)) >= shndxdata->d_size) {
 708  708                          _elf_seterr(EREQ_RAND, 0);
 709  709                          EDATA_READUNLOCKS(shndxdata);
 710  710                          return (NULL);
 711  711                  }
 712  712                  *xshndx = (((Elf32_Word *)shndxdata->d_buf)[ndx]);
 713  713                  EDATA_READUNLOCKS(shndxdata);
 714  714          } else {
 715  715                  *xshndx = 0;
 716  716          }
 717  717          return (symptr);
 718  718  }
 719  719  
 720  720  int
 721  721  gelf_update_symshndx(Elf_Data *symdata, Elf_Data *shndxdata,
 722      -        int ndx, GElf_Sym *symptr, Elf32_Word xshndx)
      722 +    int ndx, GElf_Sym *symptr, Elf32_Word xshndx)
 723  723  {
 724  724          if (gelf_update_sym(symdata, ndx, symptr) == 0)
 725  725                  return (0);
 726  726          if (shndxdata) {
 727  727                  ELFWLOCK(EDATA_ELF(shndxdata));
 728  728                  if ((ndx * sizeof (Elf32_Word)) >= shndxdata->d_size) {
 729  729                          _elf_seterr(EREQ_RAND, 0);
 730  730                          ELFUNLOCK(EDATA_ELF(shndxdata));
 731  731                          return (0);
 732  732                  }
↓ open down ↓ 351 lines elided ↑ open up ↑
1084 1084          ELFUNLOCK(EDATA_ELF(dst));
1085 1085          return (rc);
1086 1086  }
1087 1087  
1088 1088  /*
1089 1089   * If the specified object has a dynamic section, and that section
1090 1090   * contains a DT_FLAGS_1 entry, then return the value of that entry.
1091 1091   * Otherwise, return 0.
1092 1092   */
1093 1093  GElf_Xword
1094      -_gelf_getdyndtflags_1(Elf *elf)
     1094 +_gelf_getdynval(Elf *elf, GElf_Sxword tag)
1095 1095  {
1096 1096          Elf_Scn *scn = NULL;
1097 1097          Elf_Data *data;
1098 1098          GElf_Shdr shdr;
1099 1099          GElf_Dyn dyn;
1100 1100          int i, n;
1101 1101  
1102 1102          while (scn = elf_nextscn(elf, scn)) {
1103 1103                  if (gelf_getshdr(scn, &shdr) == NULL)
1104 1104                          break;
1105 1105                  if (shdr.sh_type != SHT_DYNAMIC)
1106 1106                          continue;
1107 1107                  if (data = elf_getdata(scn, NULL)) {
1108 1108                          n = shdr.sh_size / shdr.sh_entsize;
1109 1109                          for (i = 0; i < n; i++) {
1110 1110                                  (void) gelf_getdyn(data, i, &dyn);
1111      -                                if (dyn.d_tag == DT_FLAGS_1) {
     1111 +                                if (dyn.d_tag == tag) {
1112 1112                                          return (dyn.d_un.d_val);
1113 1113                                  }
1114 1114                          }
1115 1115                  }
1116 1116                  break;
1117 1117          }
1118 1118          return (0);
     1119 +}
     1120 +
     1121 +GElf_Xword
     1122 +_gelf_getdyndtflags_1(Elf *elf)
     1123 +{
     1124 +        return (_gelf_getdynval(elf, DT_FLAGS_1));
1119 1125  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX