Commit Graph

46 Commits

Author SHA1 Message Date
Nicholas Nethercote
32dd4093dc Handle a couple kinds of executable mutation: a read-only bss, and a
zero-length segment.           

MERGED FROM CVS HEAD


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3446
2005-03-26 16:22:43 +00:00
Nicholas Nethercote
0f0863110d Rename some arch-specific macros to use the more consistent "VGA_" prefix.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3432
2005-03-26 00:04:03 +00:00
Nicholas Nethercote
05fe123a9e Update copyright notice for 2005 on all relevant files. Don't bother trying
to be selective about it.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3303
2005-03-12 16:22:54 +00:00
Julian Seward
493ecf52a4 Get rid of dead code and/or localise global functions as needed to
avoid warnings from -fwarn-missing-prototypes.  vg_replace_malloc.c
has not been done yet though.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3298
2005-03-12 13:32:06 +00:00
Julian Seward
0356d27ca6 Merge in changes from the 2.4.0 line. This basically brings in the
overhaul of the thread support.  Many things are now probably broken,
but at least with --tool=none, simple and not-so-simple threaded and
non-thread programs work.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3265
2005-03-10 23:59:00 +00:00
Nicholas Nethercote
ce2585d447 Changed message at the top of files, and the startup message, and the
string in valgrind.pc.in, so that they describe Valgrind as a "dynamic
binary instrumentation framework", and don't mention platforms at all.  

I had to tweak the regtest filters a bit for this.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3178
2004-12-01 14:14:42 +00:00
Nicholas Nethercote
244787cc7f Get AMD64 slightly further before dying:
- implemented VG_(do_syscall)()
- fixed a problem in ume.c with mapping when loading, which was causing
  stage2's memory to be trashed
- fixed stage2.lds substitution so stage2 goes in the right address



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3156
2004-11-30 11:40:24 +00:00
Nicholas Nethercote
10b4595add Added beginnings of an AMD64 port, so lots of new files and directories.
It compiles, but aborts immediately if you try to run it.

I didn't include ldt.c;  I'm not sure how the LDT is used on AMD64.  It can be
added later if necessary.

While doing this, did some 64-bit cleanness fixes:
- Added necessary intermediate casts to ULong to avoid warnings when converting
  ThreadId to void* and vice versa, in vg_scheduler.c.
- Fixed VALGRIND_NON_SIMD_CALL[0123] to use 'long' as the return type.
- Fixed VALGRIND_PRINTF{,BACKTRACE} to use unsigned longs instead of unsigned
  ints, as needed.
- Converted some offsets in vg_symtab2.h from "Int" to "OffT".
- Made strlen, strncat, etc, use SizeT instead of 'unsigned int' for the length
  parameter.
- Couple of other minor things.

I had to insert some "#ifdef __amd64__" and "#ifndef __amd64__" guards in
places.  In particular, in vg_mylibc.c, some of our syscall wrappers aren't
appropriate for AMD64 because the syscall numbering is a bit different in
places.  This difference will have to be abstracted out somehow.

Also rewrote the sys_fcntl and sys_fcntl64 wrappers, as required for AMD64.

Also moved the ipc wrapper into x86, since it's not applicable for
AMD64.  However, it is applicable (I think) for ARM, so it would be nice
to work out a way to share syscall wrappers between some, but not all,
archs.  Hmm.  Also now using the real IPC constants rather than magic
numbers in the wrapper.

Other non-AMD64-related fixes:
- ARM: fixed syscall table by accounting for the fact that syscall
  numbers don't start at 0, but rather at 0x900000.
- Converted a few places to use ThreadId instead of 'int' or 'Int' for
  thread IDs.
- Added both AMD64 and ARM (which I'd forgotten) entries to valgrind.spec.in.
- Tweaked comments in various places.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3136
2004-11-29 13:54:10 +00:00
Nicholas Nethercote
2fd2f28031 Make ESZ less public.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2898
2004-11-01 18:42:23 +00:00
Nicholas Nethercote
b48ba617e0 Don't need to use addr_t anymore, use Addr instead, for consistency.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2897
2004-11-01 18:38:00 +00:00
Nicholas Nethercote
e0ff83bc39 - Make find_auxv() word-size independent.
- Introduced a new file, basic_types.h, for the basic types (eg. Int, Word).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2896
2004-11-01 18:22:05 +00:00
Nicholas Nethercote
bd2b70488d 64-bit cleanness tweaks.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2893
2004-11-01 16:52:43 +00:00
Nicholas Nethercote
c4cf15dc21 Arch-abstraction:
- Added include/x86-linux/ and include/linux/ subdirectories, with Makefile.am
  files.

- Overhauled the definitions of kernel types.  include/vg_kerneliface.h is now
  three files, include/linux/vki.h, include/x86-linux/vki_arch.h, and
  include/x86-linux/vki_arch_posixtypes.h.  These files separate the
  common/Linux and x86/Linux parts cleanly.  All code is copied verbatim from
  the relevant kernel headers, except that VKI_/vki_ prefixes are added as
  necessary to distinguish them from glibc types.  (This is done consistently,
  unlike previously when some types did not have the prefixes.)

  All code is clearly marked to show which particular header file it came from,
  and the Linux version used.  (I used 2.6.8.1, the most recent stable release,
  for all of them.)

  A few of the types changed;  this is because they changed between the older
  versions of Linux and the current 2.6.8.1.  I checked that all these changes
  were ok with respect to backwards compatibility for our purposes.

- vg_unsafe.h has been removed;  we are no longer including any kernel headers,
  as we have our own copies for everything.  This is because installed kernel
  headers are not reliable, and often cause compilation problems. (bug
  #92420 is a recent example)

- Removed some no-longer-needed header-presence tests from configure.in.

- Some code in the rest of Valgrind was changed to account for some slight
  changes in the names of our VKI_/vki_ kernel constants and types.

- Updated README_MISSING_SYSCALL_OR_IOCTL accordingly.

- Fixed off-by-one error with VKI_GDT_ENTRY_TLS_MAX (merged from stable branch)

The end result is that the kernel types situation should be much clearer, and
similar files can be created relatively easily for other architectures as
necessary.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2884
2004-10-31 18:48:21 +00:00
Nicholas Nethercote
8852fcbe1c Code formatting improvement.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2851
2004-10-26 13:32:11 +00:00
Nicholas Nethercote
ea8dfa8f34 If PIE (position-independent executables) are supported, build valgrind's
stage2 as one.  This means that we're not hard-wiring stage2 in at 0xb0000000,
which means our memory layout is a bit more flexible, yay.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2833
2004-10-25 17:18:24 +00:00
Nicholas Nethercote
7942c92bd6 Some combined cleaning up and arch-abstraction, involving UME and start-up:
- removed some assumptions that arch==x86 in Makefile.am files

- removed ume_arch.h;  moved its contents into ume.h.  There was no need for
  these to be separate.

- moved ume_go.c into an x86/ subdir;  gave it the more meaningful name
  jmp_with_stack.c in the process (the corresponding function also got the name
  change)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2757
2004-10-13 17:55:31 +00:00
Nicholas Nethercote
7440f4def2 Cleaned up ume.h by moving some functions around.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2756
2004-10-13 17:29:01 +00:00
Nicholas Nethercote
b24f257005 Arch-abstraction:
- abstract out three ELF constants


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2741
2004-10-09 19:08:08 +00:00
Tom Hughes
97e5e6382c Don't free the interpreter structure until we've actually finished
using it... Possible fix for bug 89663 spotted by Mike Cavins.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2724
2004-09-26 14:42:47 +00:00
Jeremy Fitzhardinge
4773c10ae7 Use C89 compatible local declaration.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2677
2004-09-09 08:10:42 +00:00
Jeremy Fitzhardinge
b23ba8257f Pull permissions checking out into a separate function to clean
things up a bit.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2676
2004-09-08 20:05:29 +00:00
Jeremy Fitzhardinge
0d40146c88 When loading a -fpie executable, put it where info.exebase wants it, since
it doesn't have a useful address in its phdrs.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2675
2004-09-08 20:05:02 +00:00
Jeremy Fitzhardinge
8a1746826d Use MAP_NORESERVE for potentially large mappings.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2674
2004-09-08 20:03:51 +00:00
Nicholas Nethercote
a906ab7cf4 Remove unnecessary #includes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2665
2004-09-05 22:25:13 +00:00
Nicholas Nethercote
b392873e38 Removed x86/ume_archdefs.h; moved CLIENT_BASE into x86/core_arch.h.
(CLIENT_BASE wasn't really part of UME.)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2659
2004-09-03 23:25:33 +00:00
Nicholas Nethercote
ba210a6364 Arch-abstraction step: renamed "vg_include.h" as "core.h".
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2643
2004-09-01 23:58:16 +00:00
Nicholas Nethercote
e4c301a9a1 Make error messages more informative.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2571
2004-08-05 12:16:13 +00:00
Nicholas Nethercote
1eb570df2c Restructured the as_*() functions so they are simpler and there is no implicit
global state -- the state is threaded explicitly through via function arguments
and return values.  ume.c now has no global variables, which is nice.

Also removed a redundant as_pad() call in stage2's main() which meant
layout_client_space() could be merged with layout_remaining_space().

Also removed a couple of no-longer-used variables and #defines.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2537
2004-07-30 21:50:15 +00:00
Nicholas Nethercote
4421ac53b7 Added some comments.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2531
2004-07-26 15:43:57 +00:00
Nicholas Nethercote
c4a06df097 Rename 'argv0' and 'argv1' to the more meaningful 'interp_name' and
'interp_args'.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2530
2004-07-26 15:32:47 +00:00
Nicholas Nethercote
7f9a4f8c64 Neaten up ume.h: don't export readelf(), mapelf, and struct elfinfo; improve
formatting too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2529
2004-07-26 15:28:33 +00:00
Nicholas Nethercote
38e314e56c make non-exported function static
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2525
2004-07-26 10:05:55 +00:00
Nicholas Nethercote
90308485ad Clarify error msgs
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2522
2004-07-22 12:41:12 +00:00
Nicholas Nethercote
ec09bc6f26 Add a bunch of asserts to check the results of calls to system malloc().
Assertions are arguably not the right thing here, but the practice is
widespread and we're not planning on making asserts optional, and it's a lot
better than no checking.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2499
2004-07-17 16:40:50 +00:00
Nicholas Nethercote
9fdb262d53 Check mmap() and munmap() results at startup; they can fail if a hard memory
limit is set.  This fixes bug #82722.

CCMAIL: 82722-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2496
2004-07-17 12:57:44 +00:00
Nicholas Nethercote
472d50b40a Merged Valgrind's heap and stack. This has two main advantages:
1. It simplifies various things a bit.

2. Valgrind/tools will run out of memory later than currently in many
circumstances.  This is good news esp. for Calltree.

Some things were going in V's 128MB heap, and some were going in V's 128MB map
segment.  Now all these things are going into a single 256MB map segment.
stage2 has been moved down to 0xb0000000, the start of the 256MB map segment.
The .so files needed by it are placed at 0xb1000000 (that's the map_base).

This required some bootstrapping at startup for memory -- we need to allocate
memory to create the segments skip-list which lets us allocate memory...
solution was to make the first superblock allocated a special static one.
That's pretty simple and enough to get things going.

Removed vg_glibc.c which wasn't doing anything anyway.

Removed VG_(brk) and associated stuff, made all the things that were calling it
call VG_(mmap)() instead.

Removed VG_(valgrind_mmap_end) which was no longer needed.

Rejigged the startup order a bit as necessary.

Moved an important comment from ume.c to vg_main.c where it should be.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2482
2004-07-15 12:59:41 +00:00
Tom Hughes
414846a941 Removed all uses of nested functions as they only work with gcc and
cause the stack to be marked as executable in order for them to work.

All assembler files have also had a declaration added so that the
object they generate will be marked as not needing an executable stack.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2446
2004-06-27 17:37:21 +00:00
Jeremy Fitzhardinge
d03690c430 Fix the use of brk. This change removes the requirement for the "real" brk
segment to be moved up to stage2's brk segment.  Instead, Valgrind's
use of brk is simulated with mmap.  In order to prevent any unwanted use
of the process brk segment, it also sets the RLIMIT_DATA to 0, which will
make brk always fail.  glibc's malloc will use mmap to allocate if brk
fails.  We try to intercept glibc's brk, but malloc seems to always use the
library-internal version.  (The client's use of brk has always been simulated,
and is unaffected by this change.)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2266
2004-02-24 23:42:55 +00:00
Nicholas Nethercote
aa5c98c53b Moved stage2.c into vg_main.c. Merged main() and VG_(main)(); VG_(main)()
no longer exists.  One advantage of this is that global
variables/structures needed for communicating between the two can be made
local.  Also, the order in which things happen has been simplified.

This is mostly just a big refactoring.  Startup is now a fair bit easier to
understand.  Dependencies between the various startup stages are fairly well
documented in comments.  Also, --help and --version now work properly --
eg. --help gives tool-specific help if --tool was specified.  There is still
some parts where things could be reordered and/or simplified, and where the
dependencies aren't clear.  These are marked with 'XXX'.

One new feature was added: ability to read options from ~/.valgrindrc and
./.valgrindrc.  Part of this is support for specifying tool-specific options
in the form --toolname:tool-specific-option.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2222
2004-01-24 18:18:54 +00:00
Dirk Mueller
1df018a591 remove anonymous unions - not supported by older versions of gcc.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2188
2004-01-06 16:02:29 +00:00
Jeremy Fitzhardinge
8a30151078 Fix do_exec's permission checking.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2181
2004-01-04 23:10:07 +00:00
Nicholas Nethercote
07b8e3438b Updated copyright dates for 2004. Also added a couple of missing headers and
footers to some new files.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2177
2004-01-04 16:43:23 +00:00
Julian Seward
9a14969e96 Add copyright notices to new files.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2175
2004-01-04 03:46:11 +00:00
Jeremy Fitzhardinge
391451cb5f Statically allocate a page in the client address space for trampoline
code.  Currently this is just for signal returns, but there's the start
of sysinfo/vsyscalls support, as used by the TLS libraries.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2150
2003-12-24 10:11:11 +00:00
Jeremy Fitzhardinge
1f4c6deede Auto-generate stage2.lds so that the linker script matches the local
linker.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2122
2003-12-16 22:26:45 +00:00
Jeremy Fitzhardinge
822231c4b0 Add and delete all the files which need adding and deleting.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2119
2003-12-16 02:14:00 +00:00