Flashing is used to seal the gap between the chimney and roofing material.
The use of flashing to seal the gap between a chimney and the roofing material is intended to prevent water from entering the building through that area.