|
1207 | 1207 |
|
1208 | 1208 | fd = \emprg{open}(argv[1], O\_RDWR); |
1209 | 1209 | fsz = \emprg{lseek}(fd, 0, SEEK\_END); |
1210 | | - p1 = addr = \emprg{mmap}(0, fsz, PROT\_READ|PROT\_WRITE, |
1211 | | - MAP\_SHARED, fd, 0); |
| 1210 | + p1 = addr = \emprg{mmap}(0, fsz, PROT\_READ | PROT\_WRITE, |
| 1211 | + MAP\_SHARED, fd, 0); |
1212 | 1212 | p2 = p1 + fsz - 1; |
1213 | 1213 | while(p1<p2) \{ |
1214 | | - c = *p1; *p1++ = *p2; *p2-- = c; |
| 1214 | + c = *p1; *p1++ = *p2; *p2-- = c; |
1215 | 1215 | \} |
1216 | 1216 | \emprg{munmap}(addr, fsz); |
1217 | 1217 | \emprg{close}(fd); |
|
1241 | 1241 | \begin{itemize} |
1242 | 1242 | \item loads \emph{path} unless already loaded, returns |
1243 | 1243 | a \emsl{handle} or \texttt{NULL} |
1244 | | -\item in \emph{mode} there is an OR combination of \texttt{RTLD\_NOW} (immediate |
| 1244 | +\item \emph{mode} is an OR combination of \texttt{RTLD\_NOW} (immediate |
1245 | 1245 | bind), \texttt{RTLD\_LAZY} (bound when needed), \texttt{RTLD\_GLOBAL} |
1246 | 1246 | (symbols accessible from all modules), \texttt{RTLD\_LOCAL} (symbols accessible |
1247 | 1247 | through the handle only) |
|
1300 | 1300 | For \funnm{dlopen}, the default is \texttt{RTLD\_LOCAL}. It means |
1301 | 1301 | the same library can be mapped multiple times via \funnm{dlopen} and the |
1302 | 1302 | symbols in the mapped instances of the same library will not overlap. |
1303 | | - However, all globally mapped symbols from there are shared, e.g. |
1304 | | - \texttt{errno}. |
1305 | 1303 | \end{itemize} |
1306 | 1304 | \item \label{RTLD_NEXT} Special handle \texttt{RTLD\_NEXT} searches the symbol |
1307 | 1305 | only in libraries loaded after the library that called \funnm{dlsym}. Handy for |
|
0 commit comments