boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

pt-note-phdr.before (888B)


      1     /* compute number of program headers */
      2     switch(file_type) {
      3     default:
      4     case TCC_OUTPUT_OBJ:
      5         phnum = 0;
      6         break;
      7     case TCC_OUTPUT_EXE:
      8         if (!s1->static_link)
      9             phnum = 4 + HAVE_PHDR;
     10         else
     11             phnum = 2;
     12         break;
     13     case TCC_OUTPUT_DLL:
     14         phnum = 3;
     15         break;
     16     }
     17 
     18     /* Allocate strings for section names */
     19     alloc_sec_names(s1, file_type, strsec);
     20 
     21     /* allocate program segment headers */
     22     phdr = tcc_mallocz(phnum * sizeof(ElfW(Phdr)));
     23 
     24     /* compute section to program header mapping */
     25     file_offset = layout_sections(s1, phdr, phnum, interp, strsec, &dyninf,
     26                                   sec_order);
     27 
     28     /* Fill remaining program header and finalize relocation related to dynamic
     29        linking. */
     30     if (phnum > 0) {
     31         fill_unloadable_phdr(phdr, phnum, interp, dynamic);