The following is taken from SMACNA's Architectural Sheet Metal Manual, fifth edition.
Careful consideration must be given to flashing systems where a roof joins a wall. The base flashing system must keep water from entering the building and must be designed to provide for building movement. Counter flashing serves to turn water from a wall onto the roof or base flashing.
Metal counter flashing should be used in conjunction with composition base flashings. Composition base flashing should be applied to according to the roofing manufacturer's specifications.