@@ -33,9 +33,9 @@ extern "C" void __stack_chk_fail() {
3333namespace LIBC_NAMESPACE {
3434
3535#ifdef SYS_mmap2
36- static constexpr long mmapSyscallNumber = SYS_mmap2;
36+ static constexpr long MMAP_SYSCALL_NUMBER = SYS_mmap2;
3737#elif SYS_mmap
38- static constexpr long mmapSyscallNumber = SYS_mmap;
38+ static constexpr long MMAP_SYSCALL_NUMBER = SYS_mmap;
3939#else
4040#error "mmap and mmap2 syscalls not available."
4141#endif
@@ -54,49 +54,50 @@ void init_tls(TLSDescriptor &tls_descriptor) {
5454 }
5555
5656 // We will assume the alignment is always a power of two.
57- uintptr_t tlsSize = app.tls .size & -app.tls .align ;
58- if (tlsSize != app.tls .size )
59- tlsSize += app.tls .align ;
57+ uintptr_t tls_size = app.tls .size & -app.tls .align ;
58+ if (tls_size != app.tls .size )
59+ tls_size += app.tls .align ;
6060
6161 // Per the x86_64 TLS ABI, the entry pointed to by the thread pointer is the
6262 // address of the TLS block. So, we add more size to accomodate this address
6363 // entry.
6464 // We also need to include space for the stack canary. The canary is at
6565 // offset 0x28 (40) and is of size uintptr_t.
66- uintptr_t tlsSizeWithAddr = tlsSize + sizeof (uintptr_t ) + 40 ;
66+ uintptr_t tls_size_with_addr = tls_size + sizeof (uintptr_t ) + 40 ;
6767
6868 // We cannot call the mmap function here as the functions set errno on
6969 // failure. Since errno is implemented via a thread local variable, we cannot
7070 // use errno before TLS is setup.
71- long mmapRetVal = LIBC_NAMESPACE::syscall_impl<long >(
72- mmapSyscallNumber , nullptr , tlsSizeWithAddr , PROT_READ | PROT_WRITE,
71+ long mmap_retval = LIBC_NAMESPACE::syscall_impl<long >(
72+ MMAP_SYSCALL_NUMBER , nullptr , tls_size_with_addr , PROT_READ | PROT_WRITE,
7373 MAP_ANONYMOUS | MAP_PRIVATE, -1 , 0 );
7474 // We cannot check the return value with MAP_FAILED as that is the return
7575 // of the mmap function and not the mmap syscall.
76- if (mmapRetVal < 0 && static_cast <uintptr_t >(mmapRetVal ) > -app.pageSize )
76+ if (mmap_retval < 0 && static_cast <uintptr_t >(mmap_retval ) > -app.page_size )
7777 LIBC_NAMESPACE::syscall_impl<long >(SYS_exit, 1 );
78- uintptr_t *tlsAddr = reinterpret_cast <uintptr_t *>(mmapRetVal );
78+ uintptr_t *tls_addr = reinterpret_cast <uintptr_t *>(mmap_retval );
7979
8080 // x86_64 TLS faces down from the thread pointer with the first entry
8181 // pointing to the address of the first real TLS byte.
82- uintptr_t endPtr = reinterpret_cast <uintptr_t >(tlsAddr ) + tlsSize ;
83- *reinterpret_cast <uintptr_t *>(endPtr ) = endPtr ;
82+ uintptr_t end_ptr = reinterpret_cast <uintptr_t >(tls_addr ) + tls_size ;
83+ *reinterpret_cast <uintptr_t *>(end_ptr ) = end_ptr ;
8484
85- LIBC_NAMESPACE::inline_memcpy (reinterpret_cast <char *>(tlsAddr ),
85+ LIBC_NAMESPACE::inline_memcpy (reinterpret_cast <char *>(tls_addr ),
8686 reinterpret_cast <const char *>(app.tls .address ),
8787 app.tls .init_size );
88- uintptr_t *stackGuardAddr = reinterpret_cast <uintptr_t *>(endPtr + 40 );
88+ uintptr_t *stack_guard_addr = reinterpret_cast <uintptr_t *>(end_ptr + 40 );
8989 // Setting the stack guard to a random value.
9090 // We cannot call the get_random function here as the function sets errno on
9191 // failure. Since errno is implemented via a thread local variable, we cannot
9292 // use errno before TLS is setup.
93- ssize_t stackGuardRetVal = LIBC_NAMESPACE::syscall_impl<ssize_t >(
94- SYS_getrandom, reinterpret_cast <long >(stackGuardAddr ), sizeof (uint64_t ),
93+ ssize_t stack_guard_retval = LIBC_NAMESPACE::syscall_impl<ssize_t >(
94+ SYS_getrandom, reinterpret_cast <long >(stack_guard_addr ), sizeof (uint64_t ),
9595 0 );
96- if (stackGuardRetVal < 0 )
96+ if (stack_guard_retval < 0 )
9797 LIBC_NAMESPACE::syscall_impl (SYS_exit, 1 );
9898
99- tls_descriptor = {tlsSizeWithAddr, uintptr_t (tlsAddr), endPtr};
99+ tls_descriptor = {tls_size_with_addr, reinterpret_cast <uintptr_t >(tls_addr),
100+ end_ptr};
100101 return ;
101102}
102103
@@ -181,7 +182,7 @@ extern "C" void _start() {
181182 // value. We step over it (the "+ 1" below) to get to the env values.
182183 uint64_t *env_ptr = app.args ->argv + app.args ->argc + 1 ;
183184 uint64_t *env_end_marker = env_ptr;
184- app.envPtr = env_ptr;
185+ app.env_ptr = env_ptr;
185186 while (*env_end_marker)
186187 ++env_end_marker;
187188
@@ -190,28 +191,28 @@ extern "C" void _start() {
190191
191192 // After the env array, is the aux-vector. The end of the aux-vector is
192193 // denoted by an AT_NULL entry.
193- Elf64_Phdr *programHdrTable = nullptr ;
194- uintptr_t programHdrCount ;
194+ Elf64_Phdr *program_hdr_table = nullptr ;
195+ uintptr_t program_hdr_count = 0 ;
195196 for (AuxEntry *aux_entry = reinterpret_cast <AuxEntry *>(env_end_marker + 1 );
196197 aux_entry->type != AT_NULL; ++aux_entry) {
197198 switch (aux_entry->type ) {
198199 case AT_PHDR:
199- programHdrTable = reinterpret_cast <Elf64_Phdr *>(aux_entry->value );
200+ program_hdr_table = reinterpret_cast <Elf64_Phdr *>(aux_entry->value );
200201 break ;
201202 case AT_PHNUM:
202- programHdrCount = aux_entry->value ;
203+ program_hdr_count = aux_entry->value ;
203204 break ;
204205 case AT_PAGESZ:
205- app.pageSize = aux_entry->value ;
206+ app.page_size = aux_entry->value ;
206207 break ;
207208 default :
208209 break ; // TODO: Read other useful entries from the aux vector.
209210 }
210211 }
211212
212213 app.tls .size = 0 ;
213- for (uintptr_t i = 0 ; i < programHdrCount ; ++i) {
214- Elf64_Phdr *phdr = programHdrTable + i;
214+ for (uintptr_t i = 0 ; i < program_hdr_count ; ++i) {
215+ Elf64_Phdr *phdr = program_hdr_table + i;
215216 if (phdr->p_type != PT_TLS)
216217 continue ;
217218 // TODO: p_vaddr value has to be adjusted for static-pie executables.
0 commit comments