Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2258)

Side by Side Diff: fusl/src/internal/fdpic_crt.h

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <stdint.h> 1 #include <stdint.h>
2 2
3 __attribute__((__visibility__("hidden"))) 3 __attribute__((__visibility__("hidden"))) void* __fdpic_fixup(void* map,
4 void *__fdpic_fixup(void *map, uintptr_t *a, uintptr_t *z) 4 uintptr_t* a,
5 { 5 uintptr_t* z) {
6 » /* If map is a null pointer, the program was loaded by a 6 /* If map is a null pointer, the program was loaded by a
7 » * non-FDPIC-aware ELF loader, and fixups are not needed, 7 * non-FDPIC-aware ELF loader, and fixups are not needed,
8 » * but the value for the GOT pointer is. */ 8 * but the value for the GOT pointer is. */
9 » if (!map) return (void *)z[-1]; 9 if (!map)
10 return (void*)z[-1];
10 11
11 » struct { 12 struct {
12 » » unsigned short version, nsegs; 13 unsigned short version, nsegs;
13 » » struct fdpic_loadseg { 14 struct fdpic_loadseg {
14 » » » uintptr_t addr, p_vaddr, p_memsz; 15 uintptr_t addr, p_vaddr, p_memsz;
15 » » } segs[]; 16 } segs[];
16 » } *lm = map; 17 }* lm = map;
17 » int nsegs = lm->nsegs, rseg = 0, vseg = 0; 18 int nsegs = lm->nsegs, rseg = 0, vseg = 0;
18 » for (;;) { 19 for (;;) {
19 » » while (*a-lm->segs[rseg].p_vaddr >= lm->segs[rseg].p_memsz) 20 while (*a - lm->segs[rseg].p_vaddr >= lm->segs[rseg].p_memsz)
20 » » » if (++rseg == nsegs) rseg = 0; 21 if (++rseg == nsegs)
21 » » uintptr_t *r = (uintptr_t *) 22 rseg = 0;
22 » » » (*a + lm->segs[rseg].addr - lm->segs[rseg].p_vaddr); 23 uintptr_t* r =
23 » » if (++a == z) return r; 24 (uintptr_t*)(*a + lm->segs[rseg].addr - lm->segs[rseg].p_vaddr);
24 » » while (*r-lm->segs[vseg].p_vaddr >= lm->segs[vseg].p_memsz) 25 if (++a == z)
25 » » » if (++vseg == nsegs) vseg = 0; 26 return r;
26 » » *r += lm->segs[vseg].addr - lm->segs[vseg].p_vaddr; 27 while (*r - lm->segs[vseg].p_vaddr >= lm->segs[vseg].p_memsz)
27 » } 28 if (++vseg == nsegs)
29 vseg = 0;
30 *r += lm->segs[vseg].addr - lm->segs[vseg].p_vaddr;
31 }
28 } 32 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698