Changes in / [eccd20e6:e478cebf] in mainline


Ignore:
Files:
245 added
9 deleted
31 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    reccd20e6 re478cebf  
    138138        $(USPACE_PATH)/app/blkdump/blkdump \
    139139        $(USPACE_PATH)/app/bnchmark/bnchmark \
     140        $(USPACE_PATH)/app/cc/cc \
     141        $(USPACE_PATH)/app/ccom/ccom \
     142        $(USPACE_PATH)/app/ccom/mkext/cc_mkext \
     143        $(USPACE_PATH)/app/cpp/cpp \
    140144        $(USPACE_PATH)/app/dltest/dltest \
    141145        $(USPACE_PATH)/app/dltest2/dltest2 \
  • kernel/generic/include/lib/elf.h

    reccd20e6 re478cebf  
    4242 * current ELF version
    4343 */
    44 #define EV_CURRENT  1
     44#define EV_CURRENT      1
    4545
    4646/**
    4747 * ELF types
    4848 */
    49 #define ET_NONE    0       /* No type */
    50 #define ET_REL     1       /* Relocatable file */
    51 #define ET_EXEC    2       /* Executable */
    52 #define ET_DYN     3       /* Shared object */
    53 #define ET_CORE    4       /* Core */
    54 #define ET_LOPROC  0xff00  /* Processor specific */
    55 #define ET_HIPROC  0xffff  /* Processor specific */
     49#define ET_NONE         0       /* No type */
     50#define ET_REL          1       /* Relocatable file */
     51#define ET_EXEC         2       /* Executable */
     52#define ET_DYN          3       /* Shared object */
     53#define ET_CORE         4       /* Core */
     54#define ET_LOPROC       0xff00  /* Processor specific */
     55#define ET_HIPROC       0xffff  /* Processor specific */
    5656
    5757/**
    5858 * ELF machine types
    5959 */
    60 #define EM_NO           0   /* No machine */
    61 #define EM_SPARC        2   /* SPARC */
    62 #define EM_386          3   /* i386 */
    63 #define EM_MIPS         8   /* MIPS RS3000 */
    64 #define EM_MIPS_RS3_LE  10  /* MIPS RS3000 LE */
    65 #define EM_PPC          20  /* PPC32 */
    66 #define EM_PPC64        21  /* PPC64 */
    67 #define EM_ARM          40  /* ARM */
    68 #define EM_SPARCV9      43  /* SPARC64 */
    69 #define EM_IA_64        50  /* IA-64 */
    70 #define EM_X86_64       62  /* AMD64/EMT64 */
     60#define EM_NO           0       /* No machine */
     61#define EM_SPARC        2       /* SPARC */
     62#define EM_386          3       /* i386 */
     63#define EM_MIPS         8       /* MIPS RS3000 */
     64#define EM_MIPS_RS3_LE  10      /* MIPS RS3000 LE */
     65#define EM_PPC          20      /* PPC32 */
     66#define EM_PPC64        21      /* PPC64 */
     67#define EM_ARM          40      /* ARM */
     68#define EM_SPARCV9      43      /* SPARC64 */
     69#define EM_IA_64        50      /* IA-64 */
     70#define EM_X86_64       62      /* AMD64/EMT64 */
    7171
    7272/**
    7373 * ELF identification indexes
    7474 */
    75 #define EI_MAG0        0
    76 #define EI_MAG1        1
    77 #define EI_MAG2        2
    78 #define EI_MAG3        3
    79 #define EI_CLASS       4   /* File class */
    80 #define EI_DATA        5   /* Data encoding */
    81 #define EI_VERSION     6   /* File version */
    82 #define EI_OSABI       7
    83 #define EI_ABIVERSION  8
    84 #define EI_PAD         9   /* Start of padding bytes */
    85 #define EI_NIDENT      16  /* ELF identification table size */
     75#define EI_MAG0         0
     76#define EI_MAG1         1
     77#define EI_MAG2         2
     78#define EI_MAG3         3
     79#define EI_CLASS        4               /* File class */
     80#define EI_DATA         5               /* Data encoding */
     81#define EI_VERSION      6               /* File version */
     82#define EI_OSABI        7
     83#define EI_ABIVERSION   8
     84#define EI_PAD          9               /* Start of padding bytes */
     85#define EI_NIDENT       16              /* ELF identification table size */
    8686
    8787/**
    8888 * ELF magic number
    8989 */
    90 #define ELFMAG0  0x7f
    91 #define ELFMAG1  'E'
    92 #define ELFMAG2  'L'
    93 #define ELFMAG3  'F'
     90#define ELFMAG0         0x7f
     91#define ELFMAG1         'E'
     92#define ELFMAG2         'L'
     93#define ELFMAG3         'F'
    9494
    9595/**
    9696 * ELF file classes
    9797 */
    98 #define ELFCLASSNONE  0
    99 #define ELFCLASS32    1
    100 #define ELFCLASS64    2
     98#define ELFCLASSNONE    0
     99#define ELFCLASS32      1
     100#define ELFCLASS64      2
    101101
    102102/**
    103103 * ELF data encoding types
    104104 */
    105 #define ELFDATANONE  0
    106 #define ELFDATA2LSB  1  /* Least significant byte first (little endian) */
    107 #define ELFDATA2MSB  2  /* Most signigicant byte first (big endian) */
    108 
    109 /**
    110  * ELF error return codes
    111  */
    112 #define EE_OK             0  /* No error */
    113 #define EE_INVALID        1  /* Invalid ELF image */
    114 #define EE_MEMORY         2  /* Cannot allocate address space */
    115 #define EE_INCOMPATIBLE   3  /* ELF image is not compatible with current architecture */
    116 #define EE_UNSUPPORTED    4  /* Non-supported ELF (e.g. dynamic ELFs) */
    117 #define EE_LOADER         5  /* The image is actually a program loader */
    118 #define EE_IRRECOVERABLE  6
     105#define ELFDATANONE     0
     106#define ELFDATA2LSB     1               /* Least significant byte first (little endian) */
     107#define ELFDATA2MSB     2               /* Most signigicant byte first (big endian) */
    119108
    120109/**
    121110 * ELF section types
    122111 */
    123 #define SHT_NULL      0
    124 #define SHT_PROGBITS  1
    125 #define SHT_SYMTAB    2
    126 #define SHT_STRTAB    3
    127 #define SHT_RELA      4
    128 #define SHT_HASH      5
    129 #define SHT_DYNAMIC   6
    130 #define SHT_NOTE      7
    131 #define SHT_NOBITS    8
    132 #define SHT_REL       9
    133 #define SHT_SHLIB     10
    134 #define SHT_DYNSYM    11
    135 #define SHT_LOOS      0x60000000
    136 #define SHT_HIOS      0x6fffffff
    137 #define SHT_LOPROC    0x70000000
    138 #define SHT_HIPROC    0x7fffffff
    139 #define SHT_LOUSER    0x80000000
    140 #define SHT_HIUSER    0xffffffff
     112#define SHT_NULL                0
     113#define SHT_PROGBITS            1
     114#define SHT_SYMTAB              2
     115#define SHT_STRTAB              3
     116#define SHT_RELA                4
     117#define SHT_HASH                5
     118#define SHT_DYNAMIC             6
     119#define SHT_NOTE                7
     120#define SHT_NOBITS              8
     121#define SHT_REL                 9
     122#define SHT_SHLIB               10
     123#define SHT_DYNSYM              11
     124#define SHT_LOOS                0x60000000
     125#define SHT_HIOS                0x6fffffff
     126#define SHT_LOPROC              0x70000000
     127#define SHT_HIPROC              0x7fffffff
     128#define SHT_LOUSER              0x80000000
     129#define SHT_HIUSER              0xffffffff
    141130
    142131/**
    143132 * ELF section flags
    144133 */
    145 #define SHF_WRITE      0x1
    146 #define SHF_ALLOC      0x2
    147 #define SHF_EXECINSTR  0x4
    148 #define SHF_TLS        0x400
    149 #define SHF_MASKPROC   0xf0000000
     134#define SHF_WRITE               0x1
     135#define SHF_ALLOC               0x2
     136#define SHF_EXECINSTR           0x4
     137#define SHF_TLS                 0x400
     138#define SHF_MASKPROC            0xf0000000
     139
     140/** Macros for decomposing elf_symbol.st_info into binging and type */
     141#define ELF_ST_BIND(i)          ((i) >> 4)
     142#define ELF_ST_TYPE(i)          ((i) & 0x0f)
     143#define ELF_ST_INFO(b, t)       (((b) << 4) + ((t) & 0x0f))
    150144
    151145/**
    152146 * Symbol binding
    153147 */
    154 #define STB_LOCAL   0
    155 #define STB_GLOBAL  1
    156 #define STB_WEAK    2
    157 #define STB_LOPROC  13
    158 #define STB_HIPROC  15
     148#define STB_LOCAL               0
     149#define STB_GLOBAL              1
     150#define STB_WEAK                2
     151#define STB_LOPROC              13
     152#define STB_HIPROC              15
    159153
    160154/**
    161155 * Symbol types
    162156 */
    163 #define STT_NOTYPE   0
    164 #define STT_OBJECT   1
    165 #define STT_FUNC     2
    166 #define STT_SECTION  3
    167 #define STT_FILE     4
    168 #define STT_LOPROC   13
    169 #define STT_HIPROC   15
     157#define STT_NOTYPE              0
     158#define STT_OBJECT              1
     159#define STT_FUNC                2
     160#define STT_SECTION             3
     161#define STT_FILE                4
     162#define STT_LOPROC              13
     163#define STT_HIPROC              15
    170164
    171165/**
    172166 * Program segment types
    173167 */
    174 #define PT_NULL     0
    175 #define PT_LOAD     1
    176 #define PT_DYNAMIC  2
    177 #define PT_INTERP   3
    178 #define PT_NOTE     4
    179 #define PT_SHLIB    5
    180 #define PT_PHDR     6
    181 #define PT_LOPROC   0x70000000
    182 #define PT_HIPROC   0x7fffffff
     168#define PT_NULL                 0
     169#define PT_LOAD                 1
     170#define PT_DYNAMIC              2
     171#define PT_INTERP               3
     172#define PT_NOTE                 4
     173#define PT_SHLIB                5
     174#define PT_PHDR                 6
     175#define PT_LOPROC               0x70000000
     176#define PT_HIPROC               0x7fffffff
    183177
    184178/**
    185179 * Program segment attributes.
    186180 */
    187 #define PF_X  1
    188 #define PF_W  2
    189 #define PF_R  4
     181#define PF_X    1
     182#define PF_W    2
     183#define PF_R    4
    190184
    191185/**
     
    195189 * ELF object file specifications. They are the only types used
    196190 * in ELF header.
    197  *
    198191 */
    199192typedef uint64_t elf_xword;
     
    207200 *
    208201 * These types are specific for 32-bit format.
    209  *
    210202 */
    211203typedef uint32_t elf32_addr;
     
    216208 *
    217209 * These types are specific for 64-bit format.
    218  *
    219210 */
    220211typedef uint64_t elf64_addr;
     
    238229        elf_half e_shstrndx;
    239230};
    240 
    241231struct elf64_header {
    242232        uint8_t e_ident[EI_NIDENT];
     
    256246};
    257247
    258 /**
     248/*
    259249 * ELF segment header.
    260250 * Segments headers are also known as program headers.
     
    270260        elf_word p_align;
    271261};
    272 
    273262struct elf64_segment_header {
    274263        elf_word p_type;
     
    282271};
    283272
    284 /**
     273/*
    285274 * ELF section header
    286275 */
     
    297286        elf_word sh_entsize;
    298287};
    299 
    300288struct elf64_section_header {
    301289        elf_word sh_name;
     
    311299};
    312300
    313 /**
     301/*
    314302 * ELF symbol table entry
    315303 */
     
    322310        elf_half st_shndx;
    323311};
    324 
    325312struct elf64_symbol {
    326313        elf_word st_name;
     
    332319};
    333320
     321/*
     322 * ELF note segment entry
     323 */
     324struct elf32_note {
     325        elf_word namesz;
     326        elf_word descsz;
     327        elf_word type;
     328};
     329struct elf64_note {
     330        elf_xword namesz;
     331        elf_xword descsz;
     332        elf_xword type;
     333};
     334
    334335#ifdef __32_BITS__
    335336typedef struct elf32_header elf_header_t;
     
    337338typedef struct elf32_section_header elf_section_header_t;
    338339typedef struct elf32_symbol elf_symbol_t;
     340typedef struct elf32_note elf_note_t;
    339341#endif
    340 
    341342#ifdef __64_BITS__
    342343typedef struct elf64_header elf_header_t;
     
    344345typedef struct elf64_section_header elf_section_header_t;
    345346typedef struct elf64_symbol elf_symbol_t;
     347typedef struct elf64_note elf_note_t;
    346348#endif
    347 
    348 extern const char *elf_error(unsigned int rc);
    349349
    350350/** Interpreter string used to recognize the program loader */
  • kernel/generic/include/mm/as.h

    reccd20e6 re478cebf  
    307307extern mem_backend_t phys_backend;
    308308
    309 /**
    310  * This flags is passed when running the loader, otherwise elf_load()
    311  * would return with a EE_LOADER error code.
    312  *
    313  */
    314 #define ELD_F_NONE    0
    315 #define ELD_F_LOADER  1
    316 
    317 extern unsigned int elf_load(elf_header_t *, as_t *, unsigned int);
    318 
    319309/* Address space area related syscalls. */
    320310extern sysarg_t sys_as_area_create(uintptr_t, size_t, unsigned int);
  • kernel/generic/src/lib/elf.c

    reccd20e6 re478cebf  
    4747#include <macros.h>
    4848#include <arch.h>
     49
     50#include <lib/elf_load.h>
    4951
    5052static const char *error_codes[] = {
  • kernel/generic/src/proc/program.c

    reccd20e6 re478cebf  
    4848#include <ipc/ipcrsc.h>
    4949#include <security/cap.h>
    50 #include <lib/elf.h>
     50#include <lib/elf_load.h>
    5151#include <errno.h>
    5252#include <print.h>
  • uspace/Makefile

    reccd20e6 re478cebf  
    3737        app/blkdump \
    3838        app/bnchmark \
     39        app/cc \
     40        app/ccom \
     41        app/ccom/mkext \
     42        app/cpp \
    3943        app/edit \
    4044        app/ext2info \
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    reccd20e6 re478cebf  
    169169               
    170170                /* fill the name field */
    171                 tosort[nbdirs].name = (char *) malloc(str_length(dp->d_name) + 1);
     171                tosort[nbdirs].name = (char *) malloc(str_size(dp->d_name) + 1);
    172172                if (!tosort[nbdirs].name) {
    173173                        cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
    174174                        goto out;
    175175                }
    176                
    177                 str_cpy(tosort[nbdirs].name, str_length(dp->d_name) + 1, dp->d_name);
     176
     177                str_cpy(tosort[nbdirs].name, str_size(dp->d_name) + 1, dp->d_name);
    178178                len = snprintf(buff, PATH_MAX - 1, "%s/%s", d, tosort[nbdirs].name);
    179179                buff[len] = '\0';
  • uspace/app/bdsh/exec.c

    reccd20e6 re478cebf  
    5252static int try_access(const char *);
    5353
    54 const char *search_dir[] = { "app", "srv", NULL };
     54const char *search_dir[] = { "/app", "/srv", NULL };
    5555
    5656/* work-around for access() */
  • uspace/app/taskdump/elf_core.c

    reccd20e6 re478cebf  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3838 * Looking at core files produced by Linux, these don't have section headers,
    3939 * only program headers, although objdump shows them as having sections.
    40  * Basically at the beginning there should be a note segment (which we
    41  * do not write) and one loadable segment per memory area (which we do write).
    42  *
    43  * The note segment probably contains register state, etc. -- we don't
    44  * deal with these yet. Nevertheless you can use these core files with
    45  * objdump or gdb.
    46  */
    47 
     40 * Basically at the beginning there should be a note segment followed
     41 * by one loadable segment per memory area.
     42 *
     43 * The note segment contains a series of records with register state,
     44 * process info etc. We only write one record NT_PRSTATUS which contains
     45 * process/register state (anything which is not register state we fill
     46 * with zeroes).
     47 */
     48
     49#include <align.h>
     50#include <elf/elf.h>
     51#include <elf/elf_linux.h>
    4852#include <stdio.h>
    4953#include <stdlib.h>
     
    5862#include <udebug.h>
    5963#include <macros.h>
    60 
    61 #include <elf.h>
    62 #include "include/elf_core.h"
     64#include <libarch/istate.h>
     65
     66#include "elf_core.h"
    6367
    6468static off64_t align_foff_up(off64_t, uintptr_t, size_t);
    65 static int write_all(int, void *, size_t);
     69static int write_all(int, const void *, size_t);
     70static int align_pos(int, size_t);
    6671static int write_mem_area(int, as_area_info_t *, async_sess_t *);
    6772
     
    8388 */
    8489int elf_core_save(const char *file_name, as_area_info_t *ainfo, unsigned int n,
    85     async_sess_t *sess)
     90    async_sess_t *sess, istate_t *istate)
    8691{
    8792        elf_header_t elf_hdr;
     
    9095        elf_word flags;
    9196        elf_segment_header_t *p_hdr;
     97        elf_prstatus_t pr_status;
     98        elf_note_t note;
     99        size_t word_size;
    92100
    93101        int fd;
     
    95103        unsigned int i;
    96104
    97         n_ph = n;
    98 
    99         p_hdr = malloc(sizeof(elf_segment_header_t) * n);
     105#ifdef __32_BITS__
     106        word_size = 4;
     107#endif
     108#ifdef __64_BITS__
     109        word_size = 8;
     110#endif
     111        memset(&pr_status, 0, sizeof(pr_status));
     112        istate_to_elf_regs(istate, &pr_status.regs);
     113
     114        n_ph = n + 1;
     115
     116        p_hdr = malloc(sizeof(elf_segment_header_t) * n_ph);
    100117        if (p_hdr == NULL) {
    101118                printf("Failed allocating memory.\n");
     
    115132         *      ELF header
    116133         *      program headers
     134         *      note segment
    117135         * repeat:
    118136         *      (pad for alignment)
    119          *      segment data
     137         *      core segment
    120138         * end repeat
    121139         */
     
    147165        foff = elf_hdr.e_phoff + n_ph * sizeof(elf_segment_header_t);
    148166
    149         for (i = 1; i <= n; ++i) {
    150                 foff = align_foff_up(foff, ainfo[i - 1].start_addr, PAGE_SIZE);
     167        memset(&p_hdr[0], 0, sizeof(p_hdr[0]));
     168        p_hdr[0].p_type = PT_NOTE;
     169        p_hdr[0].p_offset = foff;
     170        p_hdr[0].p_vaddr = 0;
     171        p_hdr[0].p_paddr = 0;
     172        p_hdr[0].p_filesz = sizeof(elf_note_t)
     173            + ALIGN_UP((str_size("CORE") + 1), word_size)
     174            + ALIGN_UP(sizeof(elf_prstatus_t), word_size);
     175        p_hdr[0].p_memsz = 0;
     176        p_hdr[0].p_flags = 0;
     177        p_hdr[0].p_align = 1;
     178
     179        foff += p_hdr[0].p_filesz;
     180
     181        for (i = 0; i < n; ++i) {
     182                foff = align_foff_up(foff, ainfo[i].start_addr, PAGE_SIZE);
    151183
    152184                flags = 0;
    153                 if (ainfo[i - 1].flags & AS_AREA_READ)
     185                if (ainfo[i].flags & AS_AREA_READ)
    154186                        flags |= PF_R;
    155                 if (ainfo[i - 1].flags & AS_AREA_WRITE)
     187                if (ainfo[i].flags & AS_AREA_WRITE)
    156188                        flags |= PF_W;
    157                 if (ainfo[i - 1].flags & AS_AREA_EXEC)
     189                if (ainfo[i].flags & AS_AREA_EXEC)
    158190                        flags |= PF_X;
    159191
    160                 memset(&p_hdr[i - 1], 0, sizeof(p_hdr[i - 1]));
    161                 p_hdr[i - 1].p_type = PT_LOAD;
    162                 p_hdr[i - 1].p_offset = foff;
    163                 p_hdr[i - 1].p_vaddr = ainfo[i - 1].start_addr;
    164                 p_hdr[i - 1].p_paddr = 0;
    165                 p_hdr[i - 1].p_filesz = ainfo[i - 1].size;
    166                 p_hdr[i - 1].p_memsz = ainfo[i - 1].size;
    167                 p_hdr[i - 1].p_flags = flags;
    168                 p_hdr[i - 1].p_align = PAGE_SIZE;
    169 
    170                 foff += ainfo[i - 1].size;
     192                memset(&p_hdr[i + 1], 0, sizeof(p_hdr[i + 1]));
     193                p_hdr[i + 1].p_type = PT_LOAD;
     194                p_hdr[i + 1].p_offset = foff;
     195                p_hdr[i + 1].p_vaddr = ainfo[i].start_addr;
     196                p_hdr[i + 1].p_paddr = 0;
     197                p_hdr[i + 1].p_filesz = ainfo[i].size;
     198                p_hdr[i + 1].p_memsz = ainfo[i].size;
     199                p_hdr[i + 1].p_flags = flags;
     200                p_hdr[i + 1].p_align = PAGE_SIZE;
     201
     202                foff += ainfo[i].size;
    171203        }
    172204
     
    187219        }
    188220
    189         for (i = 0; i < n_ph; ++i) {
     221        if (lseek(fd, p_hdr[0].p_offset, SEEK_SET) == (off64_t) -1) {
     222                printf("Failed writing memory data.\n");
     223                free(p_hdr);
     224                return EIO;
     225        }
     226
     227        /*
     228         * Write note header
     229         */
     230        note.namesz = str_size("CORE") + 1;
     231        note.descsz = sizeof(elf_prstatus_t);
     232        note.type = NT_PRSTATUS;
     233
     234        rc = write_all(fd, &note, sizeof(elf_note_t));
     235        if (rc != EOK) {
     236                printf("Failed writing note header.\n");
     237                free(p_hdr);
     238                return EIO;
     239        }
     240
     241        rc = write_all(fd, "CORE", note.namesz);
     242        if (rc != EOK) {
     243                printf("Failed writing note header.\n");
     244                free(p_hdr);
     245                return EIO;
     246        }
     247
     248        rc = align_pos(fd, word_size);
     249        if (rc != EOK) {
     250                printf("Failed writing note header.\n");
     251                free(p_hdr);
     252                return EIO;
     253        }
     254
     255        rc = write_all(fd, &pr_status, sizeof(elf_prstatus_t));
     256        if (rc != EOK) {
     257                printf("Failed writing register data.\n");
     258                free(p_hdr);
     259                return EIO;
     260        }
     261
     262        for (i = 1; i < n_ph; ++i) {
    190263                if (lseek(fd, p_hdr[i].p_offset, SEEK_SET) == (off64_t) -1) {
    191264                        printf("Failed writing memory data.\n");
     
    193266                        return EIO;
    194267                }
    195                 if (write_mem_area(fd, &ainfo[i], sess) != EOK) {
     268                if (write_mem_area(fd, &ainfo[i - 1], sess) != EOK) {
    196269                        printf("Failed writing memory data.\n");
    197270                        free(p_hdr);
     
    210283        off64_t rva = vaddr % page_size;
    211284        off64_t rfo = foff % page_size;
    212        
     285
    213286        if (rva >= rfo)
    214287                return (foff + (rva - rfo));
    215        
     288
    216289        return (foff + (page_size + (rva - rfo)));
    217290}
     
    268341 *                      failed.
    269342 */
    270 static int write_all(int fd, void *data, size_t len)
     343static int write_all(int fd, const void *data, size_t len)
    271344{
    272345        int cnt = 0;
     
    287360}
    288361
     362static int align_pos(int fd, size_t align)
     363{
     364        off64_t cur_pos;
     365        size_t rem, adv;
     366
     367        cur_pos = lseek(fd, 0, SEEK_CUR);
     368        if (cur_pos < 0)
     369                return -1;
     370
     371        rem = cur_pos % align;
     372        adv = align - rem;
     373
     374        cur_pos = lseek(fd, adv, SEEK_CUR);
     375        if (cur_pos < 0)
     376                return -1;
     377
     378        return EOK;
     379}
    289380
    290381/** @}
  • uspace/app/taskdump/include/elf_core.h

    reccd20e6 re478cebf  
    3737
    3838#include <async.h>
     39#include <elf/elf_linux.h>
     40#include <libarch/istate.h>
    3941
    4042extern int elf_core_save(const char *, as_area_info_t *, unsigned int,
    41     async_sess_t *);
     43    async_sess_t *, istate_t *);
    4244
    4345#endif
  • uspace/app/taskdump/include/symtab.h

    reccd20e6 re478cebf  
    3636#define SYMTAB_H_
    3737
     38#include <elf/elf.h>
    3839#include <sys/types.h>
    39 #include <elf.h>
    4040
    4141typedef struct {
  • uspace/app/taskdump/symtab.c

    reccd20e6 re478cebf  
    3636 */
    3737
     38#include <elf/elf.h>
    3839#include <stdio.h>
    3940#include <stdlib.h>
     
    4344#include <fcntl.h>
    4445
    45 #include <elf.h>
    4646#include "include/symtab.h"
    4747
  • uspace/app/taskdump/taskdump.c

    reccd20e6 re478cebf  
    3434
    3535#include <async.h>
     36#include <elf/elf_linux.h>
    3637#include <stdio.h>
    3738#include <stdlib.h>
     
    7273static char *get_app_task_name(void);
    7374static char *fmt_sym_address(uintptr_t addr);
     75
     76static istate_t reg_state;
    7477
    7578int main(int argc, char *argv[])
     
    293296        if (write_core_file) {
    294297                printf("Writing core file '%s'\n", core_file_name);
    295                 rc = elf_core_save(core_file_name, ainfo_buf, n_areas, sess);
     298
     299                rc = elf_core_save(core_file_name, ainfo_buf, n_areas, sess,
     300                    &reg_state);
     301
    296302                if (rc != EOK) {
    297303                        printf("Failed writing core file.\n");
     
    321327        pc = istate_get_pc(&istate);
    322328        fp = istate_get_fp(&istate);
     329
     330        /* Save register state for dumping to core file later. */
     331        reg_state = istate;
    323332
    324333        sym_pc = fmt_sym_address(pc);
  • uspace/lib/c/Makefile

    reccd20e6 re478cebf  
    5959-include arch/$(UARCH)/Makefile.inc
    6060
    61 EXTRA_CFLAGS += -I../../srv/loader/include
    62 
    6361GENERIC_SOURCES = \
    6462        generic/libc.c \
     
    7169        generic/device/hw_res.c \
    7270        generic/device/char_dev.c \
     71        generic/elf/elf_load.c \
    7372        generic/event.c \
    7473        generic/errno.c \
     
    134133                generic/dlfcn.c \
    135134                generic/rtld/rtld.c \
    136                 generic/rtld/elf_load.c \
    137135                generic/rtld/dynamic.c \
    138136                generic/rtld/module.c \
  • uspace/lib/c/arch/abs32le/include/types.h

    reccd20e6 re478cebf  
    5151typedef uint32_t size_t;
    5252
     53typedef int32_t intptr_t;
    5354typedef uint32_t uintptr_t;
    5455typedef uint32_t atomic_count_t;
  • uspace/lib/c/arch/amd64/include/types.h

    reccd20e6 re478cebf  
    5151typedef uint64_t size_t;
    5252
     53typedef int64_t intptr_t;
    5354typedef uint64_t uintptr_t;
    5455typedef uint64_t atomic_count_t;
  • uspace/lib/c/arch/arm32/include/types.h

    reccd20e6 re478cebf  
    5252typedef uint32_t size_t;
    5353
     54typedef int32_t intptr_t;
    5455typedef uint32_t uintptr_t;
    5556typedef uint32_t atomic_count_t;
  • uspace/lib/c/arch/ia32/include/types.h

    reccd20e6 re478cebf  
    5151typedef uint32_t size_t;
    5252
     53typedef int32_t intptr_t;
    5354typedef uint32_t uintptr_t;
    5455typedef uint32_t atomic_count_t;
  • uspace/lib/c/arch/ia64/include/types.h

    reccd20e6 re478cebf  
    6161typedef uint64_t size_t;
    6262
     63typedef int64_t intptr_t;
    6364typedef uint64_t uintptr_t;
    6465typedef uint64_t atomic_count_t;
  • uspace/lib/c/arch/mips32/include/types.h

    reccd20e6 re478cebf  
    5252typedef uint32_t size_t;
    5353
     54typedef int32_t intptr_t;
    5455typedef uint32_t uintptr_t;
    5556typedef uint32_t atomic_count_t;
  • uspace/lib/c/arch/ppc32/include/types.h

    reccd20e6 re478cebf  
    5151typedef uint32_t size_t;
    5252
     53typedef int32_t intptr_t;
    5354typedef uint32_t uintptr_t;
    5455typedef uint32_t atomic_count_t;
  • uspace/lib/c/arch/sparc64/include/types.h

    reccd20e6 re478cebf  
    5151typedef uint64_t size_t;
    5252
     53typedef int64_t intptr_t;
    5354typedef uint64_t uintptr_t;
    5455typedef uint64_t atomic_count_t;
  • uspace/lib/c/generic/io/io.c

    reccd20e6 re478cebf  
    594594                }
    595595               
    596                 buf += now;
     596                data += now;
    597597                stream->buf_head += now;
    598598                buf_free -= now;
    599599                bytes_left -= now;
    600600                total_written += now;
     601                stream->buf_state = _bs_write;
    601602               
    602603                if (buf_free == 0) {
     
    606607                }
    607608        }
    608        
    609         if (total_written > 0)
    610                 stream->buf_state = _bs_write;
    611609
    612610        if (need_flush)
  • uspace/lib/c/generic/rtld/module.c

    reccd20e6 re478cebf  
    3535 */
    3636
     37#include <adt/list.h>
     38#include <elf/elf_load.h>
     39#include <fcntl.h>
     40#include <loader/pcb.h>
    3741#include <stdio.h>
    3842#include <stdlib.h>
    3943#include <unistd.h>
    40 #include <fcntl.h>
    41 #include <adt/list.h>
    42 #include <loader/pcb.h>
    4344
    4445#include <rtld/rtld.h>
     
    4748#include <rtld/rtld_arch.h>
    4849#include <rtld/module.h>
    49 #include <elf_load.h>
    5050
    5151/** (Eagerly) process all relocation tables in a module.
     
    9393module_t *module_find(const char *name)
    9494{
    95         link_t *head = &runtime_env->modules_head;
    96 
    97         link_t *cur;
    9895        module_t *m;
    9996        const char *p, *soname;
     
    110107
    111108        /* Traverse list of all modules. Not extremely fast, but simple */
    112         DPRINTF("head = %p\n", head);
    113         for (cur = head->next; cur != head; cur = cur->next) {
     109        list_foreach(runtime_env->modules, cur) {
    114110                DPRINTF("cur = %p\n", cur);
    115111                m = list_get_instance(cur, module_t, modules_link);
     
    177173
    178174        /* Insert into the list of loaded modules */
    179         list_append(&m->modules_link, &runtime_env->modules_head);
     175        list_append(&m->modules_link, &runtime_env->modules);
    180176
    181177        return m;
     
    249245void modules_process_relocs(module_t *start)
    250246{
    251         link_t *head = &runtime_env->modules_head;
    252 
    253         link_t *cur;
    254         module_t *m;
    255 
    256         for (cur = head->next; cur != head; cur = cur->next) {
     247        module_t *m;
     248
     249        list_foreach(runtime_env->modules, cur) {
    257250                m = list_get_instance(cur, module_t, modules_link);
    258251
     
    268261void modules_untag(void)
    269262{
    270         link_t *head = &runtime_env->modules_head;
    271 
    272         link_t *cur;
    273         module_t *m;
    274 
    275         for (cur = head->next; cur != head; cur = cur->next) {
     263        module_t *m;
     264
     265        list_foreach(runtime_env->modules, cur) {
    276266                m = list_get_instance(cur, module_t, modules_link);
    277267                m->bfs_tag = false;
  • uspace/lib/c/generic/rtld/rtld.c

    reccd20e6 re478cebf  
    4444{
    4545        runtime_env = &rt_env_static;
    46         list_initialize(&runtime_env->modules_head);
     46        list_initialize(&runtime_env->modules);
    4747        runtime_env->next_bias = 0x2000000;
    4848        runtime_env->program = NULL;
  • uspace/lib/c/generic/rtld/symbol.c

    reccd20e6 re478cebf  
    3838#include <stdlib.h>
    3939
     40#include <elf/elf.h>
    4041#include <rtld/rtld.h>
    4142#include <rtld/rtld_debug.h>
    4243#include <rtld/symbol.h>
    43 #include <elf.h>
    4444
    4545/*
     
    118118        module_t *m, *dm;
    119119        elf_symbol_t *sym, *s;
    120         link_t queue_head;
     120        list_t queue;
    121121        size_t i;
    122122
     
    132132
    133133        /* Insert root (the program) into the queue and tag it */
    134         list_initialize(&queue_head);
     134        list_initialize(&queue);
    135135        start->bfs_tag = true;
    136         list_append(&start->queue_link, &queue_head);
     136        list_append(&start->queue_link, &queue);
    137137
    138138        /* If the symbol is found, it will be stored in 'sym' */
     
    140140
    141141        /* While queue is not empty */
    142         while (!list_empty(&queue_head)) {
     142        while (!list_empty(&queue)) {
    143143                /* Pop first element from the queue */
    144                 m = list_get_instance(queue_head.next, module_t, queue_link);
     144                m = list_get_instance(list_first(&queue), module_t, queue_link);
    145145                list_remove(&m->queue_link);
    146146
     
    162162                        if (dm->bfs_tag == false) {
    163163                                dm->bfs_tag = true;
    164                                 list_append(&dm->queue_link, &queue_head);
     164                                list_append(&dm->queue_link, &queue);
    165165                        }
    166166                }
     
    168168
    169169        /* Empty the queue so that we leave it in a clean state */
    170         while (!list_empty(&queue_head))
    171                 list_remove(queue_head.next);
     170        while (!list_empty(&queue))
     171                list_remove(list_first(&queue));
    172172
    173173        if (!sym) {
  • uspace/lib/c/include/rtld/elf_dyn.h

    reccd20e6 re478cebf  
    3939#include <sys/types.h>
    4040
    41 #include <elf.h>
     41#include <elf/elf.h>
    4242#include <libarch/rtld/elf_dyn.h>
    4343
  • uspace/lib/c/include/rtld/rtld.h

    reccd20e6 re478cebf  
    4949
    5050        /** List of all loaded modules including rtld and the program */
    51         link_t modules_head;
     51        list_t modules;
    5252
    5353        /** Temporary hack to place each module at different address. */
  • uspace/lib/c/include/rtld/symbol.h

    reccd20e6 re478cebf  
    3636#define LIBC_RTLD_SYMBOL_H_
    3737
     38#include <elf/elf.h>
    3839#include <rtld/rtld.h>
    39 #include <elf.h>
    4040
    4141elf_symbol_t *symbol_bfs_find(const char *name, module_t *start, module_t **mod);
  • uspace/srv/loader/Makefile

    reccd20e6 re478cebf  
    3939LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link-loader.ld
    4040
    41 EXTRA_CFLAGS = -Iinclude
    42 
    4341BINARY = loader
    4442STATIC_ONLY = y
     
    4644GENERIC_SOURCES = \
    4745        main.c \
    48         elf_load.c \
    4946        interp.s
    5047
  • uspace/srv/loader/main.c

    reccd20e6 re478cebf  
    5959#include <str.h>
    6060#include <as.h>
    61 #include <elf.h>
    62 #include <elf_load.h>
     61#include <elf/elf.h>
     62#include <elf/elf_load.h>
    6363
    6464#ifdef CONFIG_RTLD
     
    348348
    349349        /* Initialize list of loaded modules */
    350         list_initialize(&runtime_env->modules_head);
    351         list_append(&prog_mod.modules_link, &runtime_env->modules_head);
     350        list_initialize(&runtime_env->modules);
     351        list_append(&prog_mod.modules_link, &runtime_env->modules);
    352352
    353353        /* Pointer to program module. Used as root of the module graph. */
Note: See TracChangeset for help on using the changeset viewer.