Qcloud1223 / COMP461905

Course project for Operating Systems at XJTU: A basic x86-64 dynamic linker.
13 stars 4 forks source link

[bug] Instruction.md(test0 part) #6

Closed SoullAngle closed 2 years ago

SoullAngle commented 2 years ago

In Instruction.md test0 part. You provide a template code as below

// Elf64_Phdr *first_segment;
// int fd = open(path_to_library);
int prot = 0;
prot |= (first_segment->prot && PF_R)? PROT_READ : 0;  
prot |= (first_segment->prot && PF_W)? PROT_WRITE : 0;  
prot |= (first_segment->prot && PF_X)? PROT_EXEC : 0;  
// NULL means "allow OS to pick up address for you"
void *start_addr = mmap(NULL, ALIGN_UP(first_segment->p_memsz, getpagesize()), prot, 
     MAP_FILE | MAP_PRIVATE, fd, first_segment->offset);

Here, the value prot is used to get permission(R,W,X). You should use '&' but not '&&' to get the right permission!

Qcloud1223 commented 2 years ago

Fixed in c1c142c , much appreciated!