This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

About check memory over bound


Hi all,
   I have the following problem about memory:

(1) Cound gcc generate the start address and the exactly length of all
global variable in the program. If so, we could find some bugs in using
some memory functions such as memcpy, memset etc.(It often happends that
the length parameter that is passed to memcpy, memset is wrong).

  Eg:  memset( gbyarray, 0, wrong_len);
    where gbyarray is a global array of byte whose length is smaller   than
wrong_len.

(2) Could gcc add some paddings between the global variables and generate
the position informations of the paddings(may be it is the work of linker).
If so, we could find some over bound of the global variable through
checking the paddings.
  Eg:  for ( i = 0; i < wrong_index_bound; i ++)
       {
          gbyarray[i] = ...;
        }
  where gdwarray is a global array of byte whose length is smaller than
wrong_index_bound.


I am just wondering if gcc could generate some information that would help
programmer to found these bugs in program.


thanks








Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]