* elf/elf.h (ELF64_R_INFO): Cast sym value to Elf64_Xword before
	shifting.
This commit is contained in:
Ulrich Drepper 2000-06-02 00:27:08 +00:00
parent 61d655c1cb
commit 68979757bc
5 changed files with 69 additions and 43 deletions

View File

@ -1,5 +1,8 @@
2000-06-01 Ulrich Drepper <drepper@redhat.com> 2000-06-01 Ulrich Drepper <drepper@redhat.com>
* elf/elf.h (ELF64_R_INFO): Cast sym value to Elf64_Xword before
shifting.
* sysdeps/i386/elf/setjmp.S: Work around change is recent * sysdeps/i386/elf/setjmp.S: Work around change is recent
binutils. gas now emits a jump through the PLT instead of a binutils. gas now emits a jump through the PLT instead of a
relative jump if the jump target is an exported symbol. relative jump if the jump target is an exported symbol.

View File

@ -476,7 +476,7 @@ typedef struct
#define ELF64_R_SYM(i) ((i) >> 32) #define ELF64_R_SYM(i) ((i) >> 32)
#define ELF64_R_TYPE(i) ((i) & 0xffffffff) #define ELF64_R_TYPE(i) ((i) & 0xffffffff)
#define ELF64_R_INFO(sym,type) (((sym) << 32) + (type)) #define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
/* Program segment header. */ /* Program segment header. */

View File

@ -51,7 +51,7 @@ These @code{typedef}s are in @file{stdint.h}.
If you require that an integer be represented in exactly N bits, use one If you require that an integer be represented in exactly N bits, use one
of the following types, with the obvious mapping to bit size and signedness: of the following types, with the obvious mapping to bit size and signedness:
@itemize @itemize @bullet
@item int8_t @item int8_t
@item int16_t @item int16_t
@item int32_t @item int32_t
@ -68,7 +68,7 @@ size, the corresponding above type does not exist.
If you don't need a specific storage size, but want the smallest data If you don't need a specific storage size, but want the smallest data
structure with @emph{at least} N bits, use one of these: structure with @emph{at least} N bits, use one of these:
@itemize @itemize @bullet
@item int8_least_t @item int8_least_t
@item int16_least_t @item int16_least_t
@item int32_least_t @item int32_least_t
@ -84,7 +84,7 @@ that allows the fastest access while having at least N bits (and
among data structures with the same access speed, the smallest one), use among data structures with the same access speed, the smallest one), use
one of these: one of these:
@itemize @itemize @bullet
@item int8_fast_t @item int8_fast_t
@item int16_fast_t @item int16_fast_t
@item int32_fast_t @item int32_fast_t
@ -100,7 +100,7 @@ which it is being used, use one of the following. If you use these,
you should write code that takes into account the variable size and range you should write code that takes into account the variable size and range
of the integer. of the integer.
@itemize @itemize @bullet
@item intmax_t @item intmax_t
@item uintmax_t @item uintmax_t
@end itemize @end itemize

View File

@ -5,7 +5,7 @@
@cindex storage allocation @cindex storage allocation
This chapter describes how processes manage and use memory in a system This chapter describes how processes manage and use memory in a system
that uses the GNU C library. that uses the GNU C library.
The GNU C Library has several functions for dynamically allocating The GNU C Library has several functions for dynamically allocating
virtual memory in various ways. They vary in generality and in virtual memory in various ways. They vary in generality and in
@ -79,7 +79,7 @@ is at which addresses, and that process is called memory allocation.
Allocation usually brings to mind meting out scarce resources, but in Allocation usually brings to mind meting out scarce resources, but in
the case of virtual memory, that's not a major goal, because there is the case of virtual memory, that's not a major goal, because there is
generally much more of it than anyone needs. Memory allocation within a generally much more of it than anyone needs. Memory allocation within a
process is mainly just a matter of making sure that the same byte of process is mainly just a matter of making sure that the same byte of
memory isn't used to store two different things. memory isn't used to store two different things.
Processes allocate memory in two major ways: by exec and Processes allocate memory in two major ways: by exec and
@ -133,11 +133,11 @@ a contiguous range of virtual addresses. Three important segments are:
@itemize @bullet @itemize @bullet
@item @item
The @dfn{text segment} contains a program's instructions and literals and The @dfn{text segment} contains a program's instructions and literals and
static constants. It is allocated by exec and stays the same size for static constants. It is allocated by exec and stays the same size for
the life of the virtual address space. the life of the virtual address space.
@item @item
The @dfn{data segment} is working storage for the program. It can be The @dfn{data segment} is working storage for the program. It can be
@ -145,7 +145,7 @@ preallocated and preloaded by exec and the process can extend or shrink
it by calling functions as described in @xref{Resizing the Data it by calling functions as described in @xref{Resizing the Data
Segment}. Its lower end is fixed. Segment}. Its lower end is fixed.
@item @item
The @dfn{stack segment} contains a program stack. It grows as the stack The @dfn{stack segment} contains a program stack. It grows as the stack
grows, but doesn't shrink when the stack shrinks. grows, but doesn't shrink when the stack shrinks.
@ -154,7 +154,7 @@ grows, but doesn't shrink when the stack shrinks.
@node Memory Allocation @node Memory Allocation
@section Allocating Storage For a Program's Data @section Allocating Storage For Program Data
This section covers how ordinary programs manage storage for their data, This section covers how ordinary programs manage storage for their data,
including the famous @code{malloc} function and some fancier facilities including the famous @code{malloc} function and some fancier facilities
@ -280,8 +280,7 @@ any time (or never).
block and clear it. block and clear it.
* Efficiency and Malloc:: Efficiency considerations in use of * Efficiency and Malloc:: Efficiency considerations in use of
these functions. these functions.
* Aligned Memory Blocks:: Allocating specially aligned memory: * Aligned Memory Blocks:: Allocating specially aligned memory.
@code{memalign} and @code{valloc}.
* Malloc Tunable Parameters:: Use @code{mallopt} to adjust allocation * Malloc Tunable Parameters:: Use @code{mallopt} to adjust allocation
parameters. parameters.
* Heap Consistency Checking:: Automatic checking for errors. * Heap Consistency Checking:: Automatic checking for errors.
@ -383,8 +382,8 @@ The block that @code{malloc} gives you is guaranteed to be aligned so
that it can hold any type of data. In the GNU system, the address is that it can hold any type of data. In the GNU system, the address is
always a multiple of eight on most systems, and a multiple of 16 on always a multiple of eight on most systems, and a multiple of 16 on
64-bit systems. Only rarely is any higher boundary (such as a page 64-bit systems. Only rarely is any higher boundary (such as a page
boundary) necessary; for those cases, use @code{memalign} or boundary) necessary; for those cases, use @code{memalign},
@code{valloc} (@pxref{Aligned Memory Blocks}). @code{posix_memalign} or @code{valloc} (@pxref{Aligned Memory Blocks}).
Note that the memory located after the end of the block is likely to be Note that the memory located after the end of the block is likely to be
in use for something else; perhaps a block already allocated by another in use for something else; perhaps a block already allocated by another
@ -617,12 +616,13 @@ after calling @code{free} wastes memory. The size threshold for
The address of a block returned by @code{malloc} or @code{realloc} in The address of a block returned by @code{malloc} or @code{realloc} in
the GNU system is always a multiple of eight (or sixteen on 64-bit the GNU system is always a multiple of eight (or sixteen on 64-bit
systems). If you need a block whose address is a multiple of a higher systems). If you need a block whose address is a multiple of a higher
power of two than that, use @code{memalign} or @code{valloc}. These power of two than that, use @code{memalign}, @code{posix_memalign}, or
functions are declared in @file{stdlib.h}. @code{valloc}. These functions are declared in @file{stdlib.h}.
With the GNU library, you can use @code{free} to free the blocks that With the GNU library, you can use @code{free} to free the blocks that
@code{memalign} and @code{valloc} return. That does not work in BSD, @code{memalign}, @code{posix_memalign}, and @code{valloc} return. That
however---BSD does not provide any way to free such blocks. does not work in BSD, however---BSD does not provide any way to free
such blocks.
@comment malloc.h stdlib.h @comment malloc.h stdlib.h
@comment BSD @comment BSD
@ -634,6 +634,22 @@ somewhat larger block, and then returning an address within the block
that is on the specified boundary. that is on the specified boundary.
@end deftypefun @end deftypefun
@comment stdlib.h
@comment POSIX
@deftypefun int posix_memalign (void **@var{memptr}, size_t @var{alignment}, size_t @var{size})
The @code{posix_memalign} function is similar to the @code{memalign}
function in that it returns a buffer of @var{size} bytes aligned to a
multiple of @var{alignment}. But it adds one requirement to the
parameter @var{alignment}: the value must be a power of two multiple of
@code{sizeof (void *)}.
If the function succeeds in allocation memory a pointer to the allocated
memory is returned in @code{*@var{memptr}} and the return value is zero.
Otherwise the function returns an error value indicating the problem.
This function was introduced in POSIX 1003.1d.
@end deftypefun
@comment malloc.h stdlib.h @comment malloc.h stdlib.h
@comment BSD @comment BSD
@deftypefun {void *} valloc (size_t @var{size}) @deftypefun {void *} valloc (size_t @var{size})
@ -790,6 +806,14 @@ immediately. This can be useful because otherwise a crash may happen
much later, and the true cause for the problem is then very hard to much later, and the true cause for the problem is then very hard to
track down. track down.
There is one problem with @code{MALLOC_CHECK_}: in SUID or SGID binaries
it could possibly be exploited since diverging from the normal programs
behaviour it now writes something to the standard error desriptor.
Therefore the use of @code{MALLOC_CHECK_} is disabled by default for
SUID and SGID binaries. It can be enabled again by the system
administrator by adding a file @file{/etc/suid-debug} (the content is
not important it could be empty).
So, what's the difference between using @code{MALLOC_CHECK_} and linking So, what's the difference between using @code{MALLOC_CHECK_} and linking
with @samp{-lmcheck}? @code{MALLOC_CHECK_} is orthogonal with respect to with @samp{-lmcheck}? @code{MALLOC_CHECK_} is orthogonal with respect to
@samp{-lmcheck}. @samp{-lmcheck} has been added for backward @samp{-lmcheck}. @samp{-lmcheck} has been added for backward
@ -1034,7 +1058,7 @@ This is the total size of memory occupied by free (not in use) chunks.
@item int keepcost @item int keepcost
This is the size of the top-most releasable chunk that normally This is the size of the top-most releasable chunk that normally
borders the end of the heap (i.e. the high end of the virtual address borders the end of the heap (i.e. the high end of the virtual address
space's data segment). space's data segment).
@end table @end table
@ -2323,7 +2347,7 @@ The function has no effect if @var{addr} is lower than the low end of
the data segment. (This is considered success, by the way). the data segment. (This is considered success, by the way).
The function fails if it would cause the data segment to overlap another The function fails if it would cause the data segment to overlap another
segment or exceed the process' data storage limit (@pxref{Limits on segment or exceed the process' data storage limit (@pxref{Limits on
Resources}). Resources}).
The function is named for a common historical case where data storage The function is named for a common historical case where data storage
@ -2333,7 +2357,7 @@ toward it from the top of the segment and the curtain between them is
called the @dfn{break}. called the @dfn{break}.
The return value is zero on success. On failure, the return value is The return value is zero on success. On failure, the return value is
@code{-1} and @code{errno} is set accordingly. The following @code{errno} @code{-1} and @code{errno} is set accordingly. The following @code{errno}
values are specific to this function: values are specific to this function:
@table @code @table @code
@ -2392,7 +2416,7 @@ pages.
@subsection Why Lock Pages @subsection Why Lock Pages
Because page faults cause paged out pages to be paged in transparently, Because page faults cause paged out pages to be paged in transparently,
a process rarely needs to be concerned about locking pages. However, a process rarely needs to be concerned about locking pages. However,
there are two reasons people sometimes are: there are two reasons people sometimes are:
@itemize @bullet @itemize @bullet
@ -2457,7 +2481,7 @@ In Linux, locked pages aren't as locked as you might think.
Two virtual pages that are not shared memory can nonetheless be backed Two virtual pages that are not shared memory can nonetheless be backed
by the same real frame. The kernel does this in the name of efficiency by the same real frame. The kernel does this in the name of efficiency
when it knows both virtual pages contain identical data, and does it when it knows both virtual pages contain identical data, and does it
even if one or both of the virtual pages are locked. even if one or both of the virtual pages are locked.
But when a process modifies one of those pages, the kernel must get it a But when a process modifies one of those pages, the kernel must get it a
separate frame and fill it with the page's data. This is known as a separate frame and fill it with the page's data. This is known as a
@ -2639,7 +2663,7 @@ with @code{munlockall} and @code{munlock}.
address space and turn off @code{MCL_FUTURE} future locking mode. address space and turn off @code{MCL_FUTURE} future locking mode.
The return value is zero if the function succeeds. Otherwise, it is The return value is zero if the function succeeds. Otherwise, it is
@code{-1} and @code{errno} is set accordingly. The only way this @code{-1} and @code{errno} is set accordingly. The only way this
function can fail is for generic reasons that all functions and system function can fail is for generic reasons that all functions and system
calls can fail, so there are no specific @code{errno} values. calls can fail, so there are no specific @code{errno} values.

View File

@ -42,7 +42,7 @@ to a more rigorous naming convention as part of the Domain Name System
@enumerate @enumerate
@item @item
hostname hostname
@cindex hostname @cindex hostname
@item @item
domain name domain name
@ -53,16 +53,16 @@ You will note that ``hostname'' looks a lot like ``host name'', but is
not the same thing, and that people often incorrectly refer to entire not the same thing, and that people often incorrectly refer to entire
host names as ``domain names.'' host names as ``domain names.''
In DNS, the full host name is properly called the FQDN (Fully Qualified In DNS, the full host name is properly called the FQDN (Fully Qualified
Domain Name) and consists of the hostname, then a period, then the Domain Name) and consists of the hostname, then a period, then the
domain name. The domain name itself usually has multiple components domain name. The domain name itself usually has multiple components
separated by periods. So for example, a system's hostname may be separated by periods. So for example, a system's hostname may be
@samp{chicken} and its domain name might be @samp{ai.mit.edu}, so @samp{chicken} and its domain name might be @samp{ai.mit.edu}, so
its FQDN (which is its host name) is @samp{chicken.ai.mit.edu}. its FQDN (which is its host name) is @samp{chicken.ai.mit.edu}.
@cindex FQDN @cindex FQDN
Adding to the confusion, though, is that DNS is not the only name space Adding to the confusion, though, is that DNS is not the only name space
in which a computer needs to be known. Another name space is the in which a computer needs to be known. Another name space is the
NIS (aka YP) name space. For NIS purposes, there is another domain NIS (aka YP) name space. For NIS purposes, there is another domain
name, which is called the NIS domain name or the YP domain name. It name, which is called the NIS domain name or the YP domain name. It
need not have anything to do with the DNS domain name. need not have anything to do with the DNS domain name.
@ -74,7 +74,7 @@ need not have anything to do with the DNS domain name.
Confusing things even more is the fact that in DNS, it is possible for Confusing things even more is the fact that in DNS, it is possible for
multiple FQDNs to refer to the same system. However, there is always multiple FQDNs to refer to the same system. However, there is always
exactly one of them that is the true host name, and it is called the exactly one of them that is the true host name, and it is called the
canonical FQDN. canonical FQDN.
In some contexts, the host name is called a ``node name.'' In some contexts, the host name is called a ``node name.''
@ -83,7 +83,7 @@ For more information on DNS host naming, @xref{Host Names}.
@pindex hostname @pindex hostname
@pindex hostid @pindex hostid
@pindex unistd.h @pindex unistd.h
Prototypes for these functions appear in @file{unistd.h}. Prototypes for these functions appear in @file{unistd.h}.
The programs @code{hostname}, @code{hostid}, and @code{domainname} work The programs @code{hostname}, @code{hostid}, and @code{domainname} work
by calling these functions. by calling these functions.
@ -195,7 +195,7 @@ to @var{id}. Only privileged processes are permitted to do this. Usually
it happens just once, at system boot time. it happens just once, at system boot time.
The proper way to establish the primary IP address of a system The proper way to establish the primary IP address of a system
is to configure the IP address resolver to associate that IP address with is to configure the IP address resolver to associate that IP address with
the system's host name as returned by @code{gethostname}. For example, the system's host name as returned by @code{gethostname}. For example,
put a record for the system in @file{/etc/hosts}. put a record for the system in @file{/etc/hosts}.
@ -224,9 +224,9 @@ associated data type are declared in the header file
@file{sys/utsname.h}. @file{sys/utsname.h}.
@pindex sys/utsname.h @pindex sys/utsname.h
As a bonus, @code{uname} also gives some information identifying the As a bonus, @code{uname} also gives some information identifying the
particular system your program is running on. This is the same information particular system your program is running on. This is the same information
which you can get with functions targetted to this purpose described in which you can get with functions targetted to this purpose described in
@ref{Host Identification}. @ref{Host Identification}.
@ -284,7 +284,7 @@ see @ref{Host Identification}.
@item char domainname[] @item char domainname[]
This is the NIS or YP domain name. It is the same value returned by This is the NIS or YP domain name. It is the same value returned by
@code{getdomainname}; see @ref{Host Identification}. This element @code{getdomainname}; see @ref{Host Identification}. This element
is a relatively recent invention and use of it is not as portable as is a relatively recent invention and use of it is not as portable as
use of the rest of the structure. use of the rest of the structure.
@ -919,7 +919,7 @@ The file system type @var{fstype} is not known to the kernel.
The file @var{dev} is not a block device special file. The file @var{dev} is not a block device special file.
@item EBUSY @item EBUSY
@itemize @itemize @bullet
@item @item
The device is already mounted. The device is already mounted.
@ -933,7 +933,7 @@ The request is to remount read-only, but there are files open for write.
@end itemize @end itemize
@item EINVAL @item EINVAL
@itemize @itemize @bullet
@item @item
A remount was attempted, but there is no filesystem mounted over the A remount was attempted, but there is no filesystem mounted over the
@ -945,7 +945,7 @@ The supposed filesystem has an invalid superblock.
@end itemize @end itemize
@item EACCESS @item EACCESS
@itemize @itemize @bullet
@item @item
The filesystem is inherently read-only (possibly due to a switch on the The filesystem is inherently read-only (possibly due to a switch on the
@ -1110,7 +1110,7 @@ returned value.
If you don't want the parameter value returned, specify a null pointer If you don't want the parameter value returned, specify a null pointer
for @var{oldval}. for @var{oldval}.
To set the parameter, specify the address and length of the new value To set the parameter, specify the address and length of the new value
as @var{newval} and @var{newlen}. If you don't want to set the parameter, as @var{newval} and @var{newlen}. If you don't want to set the parameter,
specify a null pointer as @var{newval}. specify a null pointer as @var{newval}.
@ -1134,10 +1134,10 @@ failures that apply to all system calls, the following are the
@table @code @table @code
@item EPERM @item EPERM
The process is not permitted to access one of the components of the The process is not permitted to access one of the components of the
path of the system parameter or is not permitted to access the system parameter path of the system parameter or is not permitted to access the system parameter
itself in the way (read or write) that it requested. itself in the way (read or write) that it requested.
@c There is some indication in the Linux 2.2 code that the code is trying to @c There is some indication in the Linux 2.2 code that the code is trying to
@c return EACCESS here, but the EACCESS value never actually makes it to the @c return EACCESS here, but the EACCESS value never actually makes it to the
@c user. @c user.
@item ENOTDIR @item ENOTDIR
@ -1164,7 +1164,7 @@ small.
@end deftypefun @end deftypefun
If you have a Linux kernel with the @code{proc} filesystem, you can get If you have a Linux kernel with the @code{proc} filesystem, you can get
and set most of the same parameters by reading and writing to files in and set most of the same parameters by reading and writing to files in
the @code{sys} directory of the @code{proc} filesystem. In the @code{sys} the @code{sys} directory of the @code{proc} filesystem. In the @code{sys}
directory, the directory structure represents the hierarchical structure directory, the directory structure represents the hierarchical structure
of the parameters. E.g. you can display the free page thresholds with of the parameters. E.g. you can display the free page thresholds with
@ -1190,4 +1190,3 @@ parameters are:
@item @item
@code{bdflush} @code{bdflush}
@end itemize @end itemize